[英]In Flutter the VS Code editor throws an error - The function 'myApp' isn't defined
我是 flutter 和 dart 的初学者,我刚刚创建了我的应用程序,因为它会自动创建一个模板应用程序,它在测试文件夹中的 widget_test.dart 文件中引发错误
The function 'myApp' isn't defined.
Try importing the library that defines 'myApp', correcting the name to the name of an existing function, or defining a function named 'myApp'.
{
"resource": "/D:/development/hello_rectangle/test/widget_test.dart",
"owner": "dart",
"code": "undefined_function",
"severity": 8,
"message": "The function 'myApp' isn't defined.\nTry importing the library that defines 'myApp', correcting the name to the name of an existing function, or defining a function named 'myApp'.",
"source": "dart",
"startLineNumber": 16,
"startColumn": 29,
"endLineNumber": 16,
"endColumn": 34,
"tags": []
}
我试过升级颤振,但它不起作用!!
每当您创建一个新项目时, main.dart
文件中都会提供预先编写的代码,这有助于新用户测试他们不理解的代码,但是当我们想从头开始创建某些东西时,定义了MyApp()
在位于 Project 下的测试文件中,只需点击 Project 附近的向下箭头,您将看到测试文件,打开它并删除widget_test.dart file
一旦你删除了widget_test.dart file
,错误就会消失。
您可能正在为 application 运行测试。
您可以更改默认应用程序的代码,它开始给出错误。
您可以简单地删除该文件以避免测试应用程序,或者您可以为应用程序创建测试。
要了解有关 flutter 中测试的更多信息,请单击: https : //flutter.dev/docs/testing
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.