Flutter“在通知AnimationController的状态侦听器时引发了以下StackOverflowError:堆栈溢出”

问题描述

当我在包含使用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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...