flutterflutter-animation

Flutter : Creating animation controller in stateless widget


Is there a way to create animationController inside a stateless widget? Presently I am unable to pass vsync:this inside controller constructor...


Solution

  • No you can't because StatelessWidget doesn't implement State which SingleTickerProvider mixin is defined to work only on classes that implement it If you are looking for a clean solution see flutter hooks they let you use an animation contoller without the boilerplate needed if you use StatefulWidget