Use an explicit controller when the feature needs playback control, reversing, sequencing or a shared timing signal. That extra control also creates a lifecycle responsibility.
Own the ticker and controller
The fragment belongs in a State class using SingleTickerProviderStateMixin. The mixin supplies vsync so animation ticks are coordinated with the framework. FadeTransition is placed inside build around the intended child.
Worked example
This is a focused code fragment. Place it in the class or file described above; it is not a complete standalone app.
late final AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(vsync: this,
duration: const Duration(milliseconds: 300));
controller.forward();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
// In build: FadeTransition(opacity: controller, child: const Text('Ready'))
Read the result
The controller belongs to this State and must not be recreated in build. If an animation completion callback triggers another action, consider cancellation and whether the widget is still mounted.
Follow the controller’s lifetime
initState creates one controller tied to this State’s ticker provider. A transition widget listens to the animation signal and uses its current value for presentation. dispose stops the resource when that owner leaves the tree.
Do not create a controller inside build: rebuilding would then allocate another timeline rather than simply describing the current interface. Likewise, a callback that awaits an animation must handle cancellation and the possibility that its screen disappears.
Use the lifecycle lesson to identify ownership, and compare implicit animation before accepting explicit timing complexity. A controller is useful when it expresses a needed behavior, not because it looks more advanced.
Practice and verification
Add a reverse action and navigate away while animating. Verify there is no active-ticker disposal error. Choose an implicit alternative if you do not actually need explicit playback control.