You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`AnimatedPositioned`|`left`, `top`, `right`, etc. |
168
+
|`AnimatedScale`|`scale`|
169
+
|`AnimatedRotation`|`turns`|
170
+
|`AnimatedSwitcher`| Cross-fade between children |
171
+
|`AnimatedCrossFade`| Cross-fade between two widgets |
172
+
|`AnimatedSize`| Animates size changes of child |
173
+
|`AnimatedDefaultTextStyle`|`style`|
174
174
175
175
See [references/animated-switcher.md](references/animated-switcher.md) for `AnimatedSwitcher` patterns including custom transitions and size-change handling.
176
176
@@ -249,143 +249,7 @@ class _MyWidgetState extends State<MyWidget>
249
249
}
250
250
```
251
251
252
-
### Responding to Widget Updates
253
-
254
-
Use `didUpdateWidget` to start, stop, or reverse an animation when a property changes:
255
-
256
-
```dart
257
-
class _AnimatedGlowState extends State<AnimatedGlow>
258
-
with SingleTickerProviderStateMixin {
259
-
late final AnimationController _controller;
260
-
261
-
@override
262
-
void initState() {
263
-
super.initState();
264
-
_controller = AnimationController(
265
-
duration: Durations.long2,
266
-
vsync: this,
267
-
);
268
-
if (widget.isGlowing) {
269
-
_controller.repeat(reverse: true);
270
-
}
271
-
}
272
-
273
-
@override
274
-
void didUpdateWidget(AnimatedGlow oldWidget) {
275
-
super.didUpdateWidget(oldWidget);
276
-
if (widget.isGlowing != oldWidget.isGlowing) {
277
-
if (widget.isGlowing) {
278
-
_controller.repeat(reverse: true);
279
-
} else {
280
-
_controller.stop();
281
-
_controller.reset();
282
-
}
283
-
}
284
-
}
285
-
286
-
@override
287
-
void dispose() {
288
-
_controller.dispose();
289
-
super.dispose();
290
-
}
291
-
292
-
// ...
293
-
}
294
-
```
295
-
296
-
Do not start animations in `build()`. Use `initState` for initial playback and `didUpdateWidget` for subsequent state changes.
297
-
298
-
### Constructor Injection for Testable Controllers
299
-
300
-
Expose an optional controller parameter to allow tests to drive the animation directly:
| Animate multiple properties together |`AnimatedBuilder` with manual composition |
387
-
388
-
**Avoid subclassing `AnimatedWidget`** — couples the animation to a specific widget class, making reuse harder.
252
+
See [references/explicit-animations.md](references/explicit-animations.md) for `didUpdateWidget` patterns, constructor injection for testable controllers, and transition widget vs `AnimatedBuilder` guidance.
0 commit comments