Search code examples
flutterandroid-studiodartpubspec

Where is the 'pubspec.yaml' file? Pub.dev examples won't compile in Android Studio with Flutter Plugin without adding a path, but where is it?


I have successfully installed the Flutter plugin to Android Studio on my Windows10 system, and flutter doctor -v gives me all green check marks. However, the DART examples from pub.dev fail to compile with the error message that libraries must be added to the file 'pubspec.yaml'. Where is this file? As shown below, no such file appears in the project hierarchy?

Screen shot of Android Studio hierarchy missing pubspec.yaml


Solution

  • [enter image description here][1] [1]: https://i.sstatic.net/Y5CDd.png

    This is a default folder and file structure of a Flutter project. In your case pubspec.yaml file isn't present, which should be there. So I think this is an issue related to build. So just try to rebuild the project, and it should be cured. Just Open terminal on the Project folder and run the following commands.

    flutter clean
    flutter create <Exactly same project name>

    This should rebuilt the project.

    If this is a new project and you haven't done anything on the project yet, I will suggest to create a new project using terminal commandline, as according to me commandline with VSCode is the best way to work on flutter (Obviosusly it's based on preference).