簡體   English   中英

在 Flutter 中,VS Code 編輯器拋出錯誤 - 未定義函數“myApp”

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM