Flutter : Target file “lib/main.dart” not found

Posted by


It appears that you are having trouble with the main.dart file not being located in the lib directory. There are a number of possible causes for this issue, such as missing files or improper project configuration.

Here are some methods you can try to fix this issue:

  • Make sure the main.dart file is present in your project’s lib directory. If not, you can use the following code to create a new main.dart file in the lib directory:
  • Verify that the file path in the launch.json file is accurate if the main.dart file is present in the lib directory. The launch.json file can be found in your project’s.vscode directory. As demonstrated below, you can change the programme property to point to the appropriate file path:
  • If the issue persists, try creating a new Flutter project and copying your code over to the new project. This can help isolate any issues with your current project configuration.

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x