10
10
import 'package:flutter/widgets.dart' ;
11
11
import 'package:flutter_svg/flutter_svg.dart' ;
12
12
import 'package:flutter/services.dart' ;
13
+ import 'package:vector_graphics/vector_graphics.dart' ;
13
14
import 'package:flare_flutter/flare_actor.dart' ;
14
15
import 'package:flare_flutter/flare_controller.dart' ;
15
16
import 'package:rive/rive.dart' ;
@@ -55,6 +56,8 @@ class $AssetsUnknownGen {
55
56
class ResAssets {
56
57
ResAssets ._();
57
58
59
+ static const String package = 'example_resources' ;
60
+
58
61
static const $AssetsImagesGen images = $AssetsImagesGen ();
59
62
static const $AssetsUnknownGen unknown = $AssetsUnknownGen ();
60
63
}
@@ -64,6 +67,8 @@ class AssetGenImage {
64
67
65
68
final String _assetName;
66
69
70
+ static const String package = 'example_resources' ;
71
+
67
72
final Size ? size;
68
73
69
74
Image image ({
@@ -86,7 +91,8 @@ class AssetGenImage {
86
91
bool matchTextDirection = false ,
87
92
bool gaplessPlayback = false ,
88
93
bool isAntiAlias = false ,
89
- String ? package = 'example_resources' ,
94
+ @Deprecated ('Do not specify package for a generated library asset' )
95
+ String ? package = package,
90
96
FilterQuality filterQuality = FilterQuality .low,
91
97
int ? cacheWidth,
92
98
int ? cacheHeight,
@@ -121,7 +127,8 @@ class AssetGenImage {
121
127
122
128
ImageProvider provider ({
123
129
AssetBundle ? bundle,
124
- String ? package = 'example_resources' ,
130
+ @Deprecated ('Do not specify package for a generated library asset' )
131
+ String ? package = package,
125
132
}) {
126
133
return AssetImage (
127
134
_assetName,
@@ -136,15 +143,24 @@ class AssetGenImage {
136
143
}
137
144
138
145
class SvgGenImage {
139
- const SvgGenImage (this ._assetName);
146
+ const SvgGenImage (this ._assetName,
147
+ {this .size = null , this .isVecFormat = false });
148
+ const SvgGenImage .vec (this ._assetName,
149
+ {this .size = null , this .isVecFormat = true });
140
150
141
151
final String _assetName;
142
152
153
+ static const String package = 'example_resources' ;
154
+
155
+ final Size ? size;
156
+ final bool isVecFormat;
157
+
143
158
SvgPicture svg ({
144
159
Key ? key,
145
160
bool matchTextDirection = false ,
146
161
AssetBundle ? bundle,
147
- String ? package = 'example_resources' ,
162
+ @Deprecated ('Do not specify package for a generated library asset' )
163
+ String ? package = package,
148
164
double ? width,
149
165
double ? height,
150
166
BoxFit fit = BoxFit .contain,
@@ -160,12 +176,15 @@ class SvgGenImage {
160
176
@deprecated BlendMode colorBlendMode = BlendMode .srcIn,
161
177
@deprecated bool cacheColorFilter = false ,
162
178
}) {
163
- return SvgPicture .asset (
164
- _assetName,
179
+ return SvgPicture (
180
+ switch (isVecFormat) {
181
+ true => AssetBytesLoader (_assetName,
182
+ assetBundle: bundle, packageName: package),
183
+ false =>
184
+ SvgAssetLoader (_assetName, assetBundle: bundle, packageName: package),
185
+ },
165
186
key: key,
166
187
matchTextDirection: matchTextDirection,
167
- bundle: bundle,
168
- package: package,
169
188
width: width,
170
189
height: height,
171
190
fit: fit,
@@ -175,9 +194,8 @@ class SvgGenImage {
175
194
semanticsLabel: semanticsLabel,
176
195
excludeFromSemantics: excludeFromSemantics,
177
196
theme: theme,
178
- colorFilter: colorFilter,
179
- color: color,
180
- colorBlendMode: colorBlendMode,
197
+ colorFilter: colorFilter ??
198
+ (color == null ? null : ColorFilter .mode (color, colorBlendMode)),
181
199
clipBehavior: clipBehavior,
182
200
cacheColorFilter: cacheColorFilter,
183
201
);
@@ -193,6 +211,8 @@ class FlareGenImage {
193
211
194
212
final String _assetName;
195
213
214
+ static const String package = 'example_resources' ;
215
+
196
216
FlareActor flare ({
197
217
String ? boundsNode,
198
218
String ? animation,
@@ -236,6 +256,8 @@ class RiveGenImage {
236
256
237
257
final String _assetName;
238
258
259
+ static const String package = 'example_resources' ;
260
+
239
261
RiveAnimation rive ({
240
262
String ? artboard,
241
263
List <String > animations = const [],
@@ -244,6 +266,7 @@ class RiveGenImage {
244
266
Alignment ? alignment,
245
267
Widget ? placeHolder,
246
268
bool antialiasing = true ,
269
+ bool useArtboardSize = false ,
247
270
List <RiveAnimationController > controllers = const [],
248
271
OnInitCallback ? onInit,
249
272
}) {
@@ -256,6 +279,7 @@ class RiveGenImage {
256
279
alignment: alignment,
257
280
placeHolder: placeHolder,
258
281
antialiasing: antialiasing,
282
+ useArtboardSize: useArtboardSize,
259
283
controllers: controllers,
260
284
onInit: onInit,
261
285
);
@@ -271,6 +295,8 @@ class LottieGenImage {
271
295
272
296
final String _assetName;
273
297
298
+ static const String package = 'example_resources' ;
299
+
274
300
LottieBuilder lottie ({
275
301
Animation <double >? controller,
276
302
bool ? animate,
@@ -289,7 +315,8 @@ class LottieGenImage {
289
315
double ? height,
290
316
BoxFit ? fit,
291
317
AlignmentGeometry ? alignment,
292
- String ? package = 'example_resources' ,
318
+ @Deprecated ('Do not specify package for a generated library asset' )
319
+ String ? package = package,
293
320
bool ? addRepaintBoundary,
294
321
FilterQuality ? filterQuality,
295
322
void Function (String )? onWarning,
0 commit comments