I want to use AnimationController in the StatelessWidget class with Cubit or Bloc in a flutter, if anyone can help me with an example link to explain?
How can use AnimationController in Cubit or Bloc?
2k Views Asked by Mohammad Mirshahbazi At
3
There are 3 best solutions below
0
On
AnimationController works with TickerProviderStateMixin which means that you MUST use a statefulWidget somewhere in your widget tree.
0
On
You can check this github issue https://github.com/felangel/bloc/issues/2293. In here core bloc developers indicates that stateful widget is best practice to use when it comes to using controllers. If you use stateless widget and controller you might cause memory leak. Also If you set and init your controller inside bloc/cubit it goes against bloc principles which you mix presentation layer logic into business layer logic.
I think the general practice is to avoid using presentation layer components in Blocs. I would use Bloc to manage my state value, but run the animation components in a stateful widget.
Blocs
Animated component