Skip to content

Commit c28c537

Browse files
author
Rami AlDhafeeri
committed
update examples
1 parent fc3b740 commit c28c537

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

examples/example/lib/gen/assets.gen.dart

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import 'package:flutter/widgets.dart';
1111
import 'package:flutter_svg/flutter_svg.dart';
1212
import 'package:flutter/services.dart';
13+
import 'package:vector_graphics/vector_graphics.dart';
1314
import 'package:flare_flutter/flare_actor.dart';
1415
import 'package:flare_flutter/flare_controller.dart';
1516
import 'package:rive/rive.dart';
@@ -277,11 +278,15 @@ class AssetGenImage {
277278
}
278279

279280
class SvgGenImage {
280-
const SvgGenImage(this._assetName, {this.size = null});
281+
const SvgGenImage(this._assetName,
282+
{this.size = null, this.isVecFormat = false});
283+
const SvgGenImage.vec(this._assetName,
284+
{this.size = null, this.isVecFormat = true});
281285

282286
final String _assetName;
283287

284288
final Size? size;
289+
final bool isVecFormat;
285290

286291
SvgPicture svg({
287292
Key? key,
@@ -303,12 +308,15 @@ class SvgGenImage {
303308
@deprecated BlendMode colorBlendMode = BlendMode.srcIn,
304309
@deprecated bool cacheColorFilter = false,
305310
}) {
306-
return SvgPicture.asset(
307-
_assetName,
311+
return SvgPicture(
312+
switch (isVecFormat) {
313+
true => AssetBytesLoader(_assetName,
314+
assetBundle: bundle, packageName: package),
315+
false =>
316+
SvgAssetLoader(_assetName, assetBundle: bundle, packageName: package),
317+
},
308318
key: key,
309319
matchTextDirection: matchTextDirection,
310-
bundle: bundle,
311-
package: package,
312320
width: width,
313321
height: height,
314322
fit: fit,
@@ -318,9 +326,8 @@ class SvgGenImage {
318326
semanticsLabel: semanticsLabel,
319327
excludeFromSemantics: excludeFromSemantics,
320328
theme: theme,
321-
colorFilter: colorFilter,
322-
color: color,
323-
colorBlendMode: colorBlendMode,
329+
colorFilter: colorFilter ??
330+
(color == null ? null : ColorFilter.mode(color, colorBlendMode)),
324331
clipBehavior: clipBehavior,
325332
cacheColorFilter: cacheColorFilter,
326333
);

examples/example/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ description: A sample project using FlutterGen.
33
publish_to: 'none'
44

55
environment:
6-
sdk: '>=2.16.0 <4.0.0'
7-
flutter: '>=3.0.0'
6+
sdk: '>=3.2.0 <4.0.0'
7+
flutter: '>=3.16.0'
88

99
dependencies:
1010
flutter:

examples/example_resources/lib/gen/assets.gen.dart

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@ class $AssetsUnknownGen {
5555
class ResAssets {
5656
ResAssets._();
5757

58+
static const String package = 'example_resources';
59+
5860
static const $AssetsImagesGen images = $AssetsImagesGen();
5961
static const $AssetsUnknownGen unknown = $AssetsUnknownGen();
6062
}
6163

6264
class AssetGenImage {
63-
const AssetGenImage(this._assetName, {this.size = null});
65+
const AssetGenImage(this._assetName);
6466

6567
final String _assetName;
6668

67-
final Size? size;
69+
static const String package = 'example_resources';
6870

6971
Image image({
7072
Key? key,
@@ -86,7 +88,8 @@ class AssetGenImage {
8688
bool matchTextDirection = false,
8789
bool gaplessPlayback = false,
8890
bool isAntiAlias = false,
89-
String? package = 'example_resources',
91+
@Deprecated('Do not specify package for a generated library asset')
92+
String? package = package,
9093
FilterQuality filterQuality = FilterQuality.low,
9194
int? cacheWidth,
9295
int? cacheHeight,
@@ -121,7 +124,8 @@ class AssetGenImage {
121124

122125
ImageProvider provider({
123126
AssetBundle? bundle,
124-
String? package = 'example_resources',
127+
@Deprecated('Do not specify package for a generated library asset')
128+
String? package = package,
125129
}) {
126130
return AssetImage(
127131
_assetName,
@@ -140,11 +144,14 @@ class SvgGenImage {
140144

141145
final String _assetName;
142146

147+
static const String package = 'example_resources';
148+
143149
SvgPicture svg({
144150
Key? key,
145151
bool matchTextDirection = false,
146152
AssetBundle? bundle,
147-
String? package = 'example_resources',
153+
@Deprecated('Do not specify package for a generated library asset')
154+
String? package = package,
148155
double? width,
149156
double? height,
150157
BoxFit fit = BoxFit.contain,
@@ -153,7 +160,7 @@ class SvgGenImage {
153160
WidgetBuilder? placeholderBuilder,
154161
String? semanticsLabel,
155162
bool excludeFromSemantics = false,
156-
SvgTheme? theme,
163+
SvgTheme theme = const SvgTheme(),
157164
ColorFilter? colorFilter,
158165
Clip clipBehavior = Clip.hardEdge,
159166
@deprecated Color? color,
@@ -193,6 +200,8 @@ class FlareGenImage {
193200

194201
final String _assetName;
195202

203+
static const String package = 'example_resources';
204+
196205
FlareActor flare({
197206
String? boundsNode,
198207
String? animation,
@@ -236,6 +245,8 @@ class RiveGenImage {
236245

237246
final String _assetName;
238247

248+
static const String package = 'example_resources';
249+
239250
RiveAnimation rive({
240251
String? artboard,
241252
List<String> animations = const [],
@@ -271,6 +282,8 @@ class LottieGenImage {
271282

272283
final String _assetName;
273284

285+
static const String package = 'example_resources';
286+
274287
LottieBuilder lottie({
275288
Animation<double>? controller,
276289
bool? animate,
@@ -289,7 +302,8 @@ class LottieGenImage {
289302
double? height,
290303
BoxFit? fit,
291304
AlignmentGeometry? alignment,
292-
String? package = 'example_resources',
305+
@Deprecated('Do not specify package for a generated library asset')
306+
String? package = package,
293307
bool? addRepaintBoundary,
294308
FilterQuality? filterQuality,
295309
void Function(String)? onWarning,

examples/example_resources/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ description: A sample project using FlutterGen.
33
publish_to: 'none'
44

55
environment:
6-
sdk: '>=2.16.0 <4.0.0'
7-
flutter: '>=3.0.0'
6+
sdk: '>=3.2.0 <4.0.0'
7+
flutter: '>=3.16.0'
88

99
dependencies:
1010
flutter:

0 commit comments

Comments
 (0)