createController method

AnimationController createController({
  1. bool unbounded = false,
  2. int? fps,
})

Creates an additional AnimationController instance that gets initialized and disposed by this mixin.

Optionally you can limit the framerate (fps) by specifying a target fps value.

You can create an unbound AnimationController by setting the unbounded parameter.

Example: (using supercharged)

class _MyAnimatedWidgetState extends State<MyAnimatedWidget>
    with AnimationMixin { // <-- use AnimationMixin

  AnimationController sizeController; // <-- declare custom AnimationController
  Animation<double> size;

  @override
  void initState() {
    sizeController = createController(); // <-- create custom AnimationController
    size = 0.0.tweenTo(100.0).animatedBy(sizeController); // <-- animate "size" with custom AnimationController
    sizeController.play(duration: 5.seconds); // <-- start playback on custom AnimationController
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(width: size.value, height: size.value, color: Colors.red);
  }
}

Implementation

AnimationController createController({
  bool unbounded = false,
  int? fps,
}) {
  final instance = _newAnimationController(unbounded: unbounded, fps: fps);
  _controllerInstances.add(instance);
  return instance;
}