Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 加载包引发异常_Flutter - Fatal编程技术网

Flutter 加载包引发异常

Flutter 加载包引发异常,flutter,Flutter,我使用加载包在获取数据时显示加载屏幕。它似乎工作正常,但我在控制台中看到以下错误: [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 671 pos 7: '_ticker != null': AnimationController.animateWit

我使用加载包在获取数据时显示加载屏幕。它似乎工作正常,但我在控制台中看到以下错误:

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 671 pos 7: '_ticker != null': AnimationController.animateWith() called after AnimationController.dispose()
调用dispose后不应使用AnimationController方法

  Widget getLoadingBar() {
    return new Container(

      color: Colors.blue
      child: Center(
        child: Loading(indicator: BallPulseIndicator(), size: 100.0),
      ),
    );
  }
return MaterialApp(
        home: Scaffold(
            body: Container(
                decoration: BoxDecoration(
                  gradient: new LinearGradient(colors: [Colors.yellow,    Colors.blue, Colors.red, Colors.yellow], begin: Alignment.topCenter, end: Alignment.bottomCenter, tileMode: TileMode.clamp),
                ),
                child: dataFetched ? getContent() : getLoadingBar(),
            )
        ),
      );
异步获取完成后,在setState调用中,dataFetched bool被设置为true


提前谢谢。您必须处理好您的AnimationController或任何其他控制器

void dispose(){
  _animationController.dispose(); 
}
2.如果你在程序中调用setState,那么像这样包装它

 if(this.mounted){
   setState((){
      // your code .....
   });

1.我没有对加载包中使用的animationController的引用。2.您能解释一下为什么我应该包装setState调用吗?当project构建它生成小部件树并为每个小部件分配mounted为true时,如果小部件不是树的一部分,则卸载该小部件,以便检查该小部件是否是小部件的一部分。你可以查一下