gpt4 book ai didi

flutter - 使用 SingleTickerProviderStateMixin 时热重载会抛出错误 #42054

转载 作者:行者123 更新时间:2023-12-04 14:44:11 36 4
gpt4 key购买 nike

我在一些页面中实现了动画,并且我使用了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/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com