@@ -113,6 +113,10 @@ class PaintModel with EquatableMixin, SerializableMixin {
113113 /// A reference to the GIF embedded in this node, if the image is a GIF.
114114 final String ? imageHash;
115115
116+ /// Marks this image paint model as coming from a specific asset from the
117+ /// asset library.
118+ final String ? assetID;
119+
116120 /// The sizing behavior the image will use to fit inside its view.
117121 /// This is 1-1 with Flutter's [BoxFit] .
118122 final Fit fit;
@@ -168,35 +172,35 @@ class PaintModel with EquatableMixin, SerializableMixin {
168172
169173 /// Helper constructor for when a black paint is needed, like tests.
170174 static PaintModel get blackPaint => PaintModel .solid (
171- visible: true ,
172- opacity: 1.0 ,
173- color: ColorRGB .black,
174- );
175+ visible: true ,
176+ opacity: 1.0 ,
177+ color: ColorRGB .black,
178+ );
175179
176180 /// Helper constructor for when a grey paint is needed, like tests.
177181 static PaintModel get greyPaint => PaintModel .solid (
178- visible: true ,
179- opacity: 1.0 ,
180- color: ColorRGB .grey,
181- );
182+ visible: true ,
183+ opacity: 1.0 ,
184+ color: ColorRGB .grey,
185+ );
182186
183187 /// Helper constructor for when a white paint is needed, like tests.
184188 static PaintModel get whitePaint => PaintModel .solid (
185- visible: true ,
186- opacity: 1.0 ,
187- color: ColorRGB .white,
188- );
189+ visible: true ,
190+ opacity: 1.0 ,
191+ color: ColorRGB .white,
192+ );
189193
190194 /// Helper constructor for when a gradient paint is needed, like tests.
191195 static PaintModel get linearPaint => PaintModel (
192- type: PaintType .gradientLinear,
193- visible: true ,
194- opacity: 1.0 ,
195- gradientStops: const [
196- ColorStop (color: ColorRGBA .black, position: 0.0 ),
197- ColorStop (color: ColorRGBA .white, position: 1.0 ),
198- ],
199- );
196+ type: PaintType .gradientLinear,
197+ visible: true ,
198+ opacity: 1.0 ,
199+ gradientStops: const [
200+ ColorStop (color: ColorRGBA .black, position: 0.0 ),
201+ ColorStop (color: ColorRGBA .white, position: 1.0 ),
202+ ],
203+ );
200204
201205 /// Create a Solid Paint with only the required properties.
202206 PaintModel .solid ({
@@ -222,7 +226,8 @@ class PaintModel with EquatableMixin, SerializableMixin {
222226 scaleY = 1 ,
223227 imageRepeat = ImageRepeatEnum .noRepeat,
224228 sourceWidth = null ,
225- sourceHeight = null ;
229+ sourceHeight = null ,
230+ assetID = null ;
226231
227232 /// Create an Image Paint with only the required properties.
228233 PaintModel .image ({
@@ -244,6 +249,7 @@ class PaintModel with EquatableMixin, SerializableMixin {
244249 this .imageName,
245250 required this .sourceWidth,
246251 required this .sourceHeight,
252+ this .assetID,
247253 }) : assert (sourceWidth != null && sourceHeight != null ,
248254 'Images must always provide their original size.' ),
249255 id = id ?? generateId (),
@@ -276,7 +282,8 @@ class PaintModel with EquatableMixin, SerializableMixin {
276282 imageRepeat = ImageRepeatEnum .noRepeat,
277283 croppedImageURL = null ,
278284 sourceWidth = null ,
279- sourceHeight = null ;
285+ sourceHeight = null ,
286+ assetID = null ;
280287
281288 /// Creates [PaintModel] with radial gradient.
282289 PaintModel .radialGradient ({
@@ -302,7 +309,8 @@ class PaintModel with EquatableMixin, SerializableMixin {
302309 croppedImageURL = null ,
303310 imageRepeat = ImageRepeatEnum .noRepeat,
304311 sourceWidth = null ,
305- sourceHeight = null ;
312+ sourceHeight = null ,
313+ assetID = null ;
306314
307315 /// Creates [PaintModel] with angular gradient.
308316 PaintModel .angularGradient ({
@@ -328,7 +336,8 @@ class PaintModel with EquatableMixin, SerializableMixin {
328336 cropData = null ,
329337 croppedImageURL = null ,
330338 sourceWidth = null ,
331- sourceHeight = null ;
339+ sourceHeight = null ,
340+ assetID = null ;
332341
333342 /// Creates [PaintModel] with given data.
334343 PaintModel ({
@@ -353,6 +362,7 @@ class PaintModel with EquatableMixin, SerializableMixin {
353362 this .imageName,
354363 this .sourceWidth,
355364 this .sourceHeight,
365+ this .assetID,
356366 this .imageRepeat = ImageRepeatEnum .noRepeat,
357367 }) : id = id ?? generateId ();
358368
@@ -370,6 +380,7 @@ class PaintModel with EquatableMixin, SerializableMixin {
370380 String ? downloadUrl,
371381 String ? imageName,
372382 String ? imageHash,
383+ String ? assetID,
373384 Fit ? fit,
374385 AlignmentModel ? alignment,
375386 double ? scaleX,
@@ -407,6 +418,7 @@ class PaintModel with EquatableMixin, SerializableMixin {
407418 cropData: clearCropData ? null : cropData ?? this .cropData,
408419 croppedImageURL:
409420 clearCropData ? null : croppedImageURL ?? this .croppedImageURL,
421+ assetID: assetID ?? this .assetID,
410422 imageRepeat: imageRepeat ?? this .imageRepeat,
411423 );
412424
@@ -455,6 +467,7 @@ class PaintModel with EquatableMixin, SerializableMixin {
455467 imageName: imageName,
456468 imageRepeat: imageRepeat,
457469 imageTransform: imageTransform,
470+ assetID: assetID,
458471 );
459472 case PaintType .emoji:
460473 throw Exception ('Paint type $type is not supported' );
@@ -484,6 +497,7 @@ class PaintModel with EquatableMixin, SerializableMixin {
484497 sourceWidth,
485498 sourceHeight,
486499 imageRepeat,
500+ assetID,
487501 ];
488502
489503 /// Factory constructor for creating [PaintModel] instance from a JSON data.
0 commit comments