问题描述
当我在包含使用setState
的窗口小部件的页面上调用AnimationController
方法时发生了问题。
════════动画库捕获到异常 ═════════════════════════════════
以下StackOverflowError是 通知AnimationController的状态侦听器时抛出:堆栈 溢出引发异常时,这是堆栈
#0 _WordWrapParseMode.values包:Flutter /…/ foundation / diagnostics.dart:776
#1 _SyncIterator.moveNext(dart:core-patch / core_patch.dart:165:25))
#2 Iterable.length(dart:core / iterable.dart:429:15))
#3 _PrefixedStringBuilder._finalizeLine包:Flutter /…/ foundation / diagnostics.dart:856
#4 _PrefixedStringBuilder.write包:Flutter /…/ foundation / diagnostics.dart:973
...
的 AnimationController通知状态侦听器为: AnimationController#309d2(⏮0.000;已暂停) ══════════════════════════════════════════════════ ══════════════════════════════
这是我的代码。
class SecurityHeaderComponent extends StatefulWidget {
SecurityHeaderComponent({Key key}) : super(key: key);
@override
_SecurityHeaderComponentState createState() =>
_SecurityHeaderComponentState();
}
class _SecurityHeaderComponentState extends State<SecurityHeaderComponent>
with TickerProviderStateMixin {
AnimationController _oRotateController;
AnimationController _iRotateController;
@override
void initState() {
_oRotateController = AnimationController(
vsync: this,duration: Duration(seconds: 2),);
_oRotateController.forward();
_iRotateController = AnimationController(
vsync: this,);
_iRotateController.reverse(from: _iRotateController.upperBound);
super.initState();
}
@override
void dispose() {
_oRotateController.dispose();
_iRotateController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
height: 200.0,decoration: Boxdecoration(color: MyColors.tb_security_blue_color),child: Center(
child: Stack(
children: [
Center(
child: Image(
image: ImageUtils.getAssetimage("1fixed_safetyprotection"),width: 130,height: 130,),Center(
child: RotationTransition(
child: Image(
image: ImageUtils.getAssetimage('circle_13@3x'),width: 188,height: 188,turns: _oRotateController
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
_oRotateController.reset();
_oRotateController.forward();
}
}),Center(
child: RotationTransition(
child: Image(
image: ImageUtils.getAssetimage('circle_23@3x'),width: 136,height: 136,turns: _iRotateController
..addStatusListener((status) {
if (status == AnimationStatus.dismissed) {
_iRotateController.reset();
_iRotateController.reverse(
from: _iRotateController.upperBound);
}
}),)
],);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)