Skip to content

Commit abc6838

Browse files
committed
fix: Notify the component when ColorEffect resets its color filter
1 parent 5334a1f commit abc6838

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

packages/flame/lib/src/effects/color_effect.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ class ColorEffect extends ComponentEffect<HasPaint> {
5353
void reset() {
5454
super.reset();
5555
target.getPaint(paintId).colorFilter = _original;
56+
target.onChanged();
5657
}
5758
}

packages/flame/test/effects/color_effect_test.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,32 @@ void main() {
9696
},
9797
);
9898

99+
testWithFlameGame(
100+
'reset notifies the component of the restored color filter',
101+
(game) async {
102+
final component = TextComponent<TextPaint>(text: 'foo');
103+
await game.ensureAdd(component);
104+
105+
final effect = ColorEffect(
106+
Colors.red,
107+
EffectController(duration: 1),
108+
);
109+
await component.ensureAdd(effect);
110+
game.update(0.5);
111+
expect(
112+
component.textRenderer.style.foreground!.colorFilter,
113+
isNotNull,
114+
);
115+
116+
effect.reset();
117+
118+
expect(
119+
component.textRenderer.style.foreground!.colorFilter,
120+
isNull,
121+
);
122+
},
123+
);
124+
99125
testWithFlameGame(
100126
'can be re-added in the component tree',
101127
(game) async {

0 commit comments

Comments
 (0)