@@ -137,6 +137,7 @@ class Effect with EquatableMixin, SerializableMixin {
137137
138138 /// Duplicates this instance with given data overrides.
139139 Effect copyWith ({
140+ String ? id,
140141 EffectType ? type,
141142 double ? radius,
142143 bool ? visible,
@@ -146,7 +147,7 @@ class Effect with EquatableMixin, SerializableMixin {
146147 BlendModeC ? blendMode,
147148 }) =>
148149 Effect (
149- id: id,
150+ id: id ?? this .id ,
150151 type: type ?? this .type,
151152 radius: radius ?? this .radius,
152153 visible: visible ?? this .visible,
@@ -156,6 +157,27 @@ class Effect with EquatableMixin, SerializableMixin {
156157 blendMode: blendMode ?? this .blendMode,
157158 );
158159
160+ /// [Effect] can store all types of effects at the same time to allow
161+ /// switching between different effect types. However, this is not the desired
162+ /// behavior when applying a effect to another node. This method returns a
163+ /// sanitized version of this effect model that only contains the data relevant
164+ /// to the current effect type.
165+ ///
166+ /// Resembles [PaintModel.sanitize] . There are no properties to be sanitized
167+ /// for [Effect] at the moment.
168+ Effect sanitize ({bool changeIds = false }) {
169+ switch (type) {
170+ case EffectType .dropShadow:
171+ return copyWith (id: changeIds ? generateId () : id);
172+ case EffectType .innerShadow:
173+ return copyWith (id: changeIds ? generateId () : id);
174+ case EffectType .layerBlur:
175+ return copyWith (id: changeIds ? generateId () : id);
176+ case EffectType .backgroundBlur:
177+ return copyWith (id: changeIds ? generateId () : id);
178+ }
179+ }
180+
159181 @override
160182 List <Object ?> get props => [
161183 id,
0 commit comments