The following assertion was thrown building TweenAnimationBuilder<double>(duration: 10000ms, dirty,

报错信息如下:
The following assertion was thrown building TweenAnimationBuilder(duration: 10000ms, dirty, state: _TweenAnimationBuilderState#7d4e7(ticker active)):
setState() or markNeedsBuild() called during build.

This Overlay widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
The widget on which setState() or markNeedsBuild() was called was: Overlay-[LabeledGlobalKey#ae864]
state: OverlayState#f5c42(entries: [OverlayEntry#9d580(opaque: true; maintainState: false), OverlayEntry#5e034(opaque: false; maintainState: true), OverlayEntry#c03ca(opaque: false; maintainState: false), OverlayEntry#3459a(opaque: false; maintainState: true)])
The widget which was currently being built when the offending call was made was: TweenAnimationBuilder

代码如下:其中关键代码如下,需要使用 Future.delayed()方法来延迟一秒执行,如下面的代码中,方式一会导致出现问题,方式二则可以

 				if (value >= 1.0) {
                  Get.off(() => MainPage());		/// 方式一
                  Future.delayed(Duration(seconds: 1), () {	/// 方式二
                     Get.off(() => MainPage());
                  });
                }

具体代码如下:

 bottomSheet: Container(
          height: 15,
          alignment: Alignment.bottomCenter,
          margin: EdgeInsets.only(bottom: 50),
          // color: Colors.black,
          child: SizedBox(
            width: 300,
            height: 10,
            child: TweenAnimationBuilder<double>(
              tween: Tween(begin: 0.0, end: 1.0),
              duration: Duration(seconds: 10),
              builder: (context, value, child) {
                if (value >= 1.0) {
                  Get.off(() => MainPage());
                  Future.delayed(Duration(seconds: 1), () {
                     Get.off(() => MainPage());
                  });
                }
                return GradientLinearProgressBar(
                  strokeCapRound: true,
                  strokeWidth: 10,
                  colors: [
                    HexColor(Colorss.progressSplashColor1),
                    HexColor(Colorss.progressSplashColor2)
                  ],
                  backgroundColor: Colors.black12,
                  value: value,
                );
              },
            ),
          ),
        ),
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值