Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hot reload throws error when SingleTickerProviderStateMixin is used #42054

I implemented animation in some pages, and I have used SingleTickerProviderStateMixin, when I hot reload the screen, it throws an error as follows.

If a State is used for multiple AnimationController objects, or if it is passed to other objects and those objects might use it more than one time in total, then instead of mixing in a SingleTickerProviderStateMixin, use a regular TickerProviderStateMixin.

E/flutter ( 7919): [ERROR:flutter/shell/common/shell.cc(178)] Dart Error: Unhandled exception:
E/flutter ( 7919): _SplashState is a SingleTickerProviderStateMixin but multiple tickers were created.
E/flutter ( 7919): A SingleTickerProviderStateMixin can only be used as a TickerProvider once. If a State is used for multiple AnimationController objects, or if it is passed to other objects and those objects might use it more than one time in total, then instead of mixing in a SingleTickerProviderStateMixin, use a regular TickerProviderStateMixin.
like image 599
Ayoub Boumzebra Avatar asked Dec 18 '22 11:12

Ayoub Boumzebra


1 Answers

I used TickerProviderStateMixin instead of SingleTickerProviderStateMixin.

I figured out that I used a sub widget that uses animation as well, so it counts as multiple AnimationController objects.

like image 140
Ayoub Boumzebra Avatar answered May 24 '23 18:05

Ayoub Boumzebra