【问题标题】:error: The function 'MyApp' isn't defined. (undefined_function at [i_am_a_rich_man] test\widget_test.dart:16)错误:未定义函数“MyApp”。 ([i_am_a_rich_man] test\widget_test.dart:16 处的未定义函数)
【发布时间】:2021-10-05 01:54:16
【问题描述】:
import 'package:flutter/material.dart';

void main() { 
    runApp(MaterialApp(home: Text('Snap''Kids')));
}

【问题讨论】:

    标签: flutter dart flutter-test


    【解决方案1】:

    您的根目录中应该有一个名为test 的文件夹。当您创建一个新应用程序时,它会自动在widget_test.dart 中为MyApp 创建一个测试。既然你已经删除了MyApp,你应该只是删除test/widget_test.dart中的文件。

    【讨论】:

      【解决方案2】:
          Update your method under main() method like this-
          
          void main() {
          runApp(MyApp(home: Text('Snap''Kids')));
          }
          
          OR 
          
          Goto widget_test.dart under test directory, and update
          
          await tester.pumpWidget(MyApp());
          to
          await tester.pumpWidget(MaterialApp());
      
       Give correct sign if you find it working.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-09
        • 2018-07-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多