I am very beginner in flutter and dart, I just created my app and as it automatically creates a template app, It throws an error in widget_test.dart file in test folder
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": []
}
I've tried upgrading flutter but it won't work!!
Whenever you create a new project, pre-written code is available in the main.dart
file, which helps a new user to test code that they don't understand, but when we want to create something from scratch, MyApp()
is defined in a test file whose location is under Project , just tap on downward arrow just near the Project and you will see test file , open it and delete widget_test.dart file
Once you delete the widget_test.dart file
, the error disappears.
You probably running test for application .
You may change code of default application and it start giving error.
you can simply delete that file to avoid test application or you can create test for application.
To learn more about test in flutter click: https://flutter.dev/docs/testing
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.