我在一些页面中实现了动画,并且我使用了SingleTickerProviderStateMixin,当我热重载屏幕时,它会抛出如下错误。
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.
最佳答案
我用过 TickerProviderStateMixin
而不是 SingleTickerProviderStateMixin
.
我发现我使用了一个也使用动画的子小部件,所以它算作多个 AnimationController
对象。
关于flutter - 使用 SingleTickerProviderStateMixin 时热重载会抛出错误 #42054,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66709256/