当尝试Widget of flutter时,抛出了NoSuchMethodError,称该方法' _debugTypesAreRight'在null上调用

时间:2018-05-29 13:12:35

标签: android-studio dart flutter

我正在尝试一个简单的扑动飞镖计划。我指的是this教程,我该如何解决这个问题?

获得以下异常

I/flutter ( 4785): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 4785): The following NoSuchMethodError was thrown attaching to the render tree:
I/flutter ( 4785): The method '_debugTypesAreRight' was called on null.
I/flutter ( 4785): Receiver: null
I/flutter ( 4785): Tried calling: _debugTypesAreRight(Instance of 'RealWorldApp')

代码是:

import 'package:flutter/material.dart';

void main() => runApp(new RealWorldApp());

class RealWorldApp extends StatefulWidget {
  @override
  RealWorldState createState() => new RealWorldState();

}
 class RealWorldState extends State<RealWorldApp>
  {
  @override
  Widget build(BuildContext context) {
  return new MaterialApp(
    home: new Scaffold(
      appBar: new AppBar(
        title: new Text("First App"),
        actions: <Widget>[
          new IconButton(icon: new Icon(Icons.refresh),
          )
        ],
      ),
      body: new Center(
        child: new CircularProgressIndicator(),
      ),
    ),
  );
  }

  }

1 个答案:

答案 0 :(得分:1)

绝对是某种错误。从终端尝试flutter clean删除build / *然后重新编译,让我知道它是否仍然坏了。如果是,请尝试执行flutter upgradeflutter packages get,然后再次清理并重建。如果 不起作用,请提供完整日志输出,以便我们可以看到堆栈跟踪。