controller property
AnimationController
get
controller
Returns the main AnimationController instance for this state class.
Example: (using supercharged)
class _MyAnimatedWidgetState extends State<MyAnimatedWidget>
with AnimationMixin { // Add AnimationMixin to state class
Animation<double> size; // Declare animation variable
@override
void initState() {
size = 0.0.tweenTo(200.0).animatedBy(controller); // Connect tween and controller and apply to animation variable
controller.play(); // Start the animation playback
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
width: size.value, // Use animation variable's value here
height: size.value, // Use animation variable's value here
color: Colors.red
);
}
}
Implementation
AnimationController get controller {
_mainControllerInstance ??= _newAnimationController();
return _mainControllerInstance!;
}