Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 354
PiyushK Avatar asked May 28 '26 00:05

PiyushK


1 Answers

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

like image 176
Haidar Avatar answered May 31 '26 19:05

Haidar