I am using Windows 10 with VS Code, although I also tested it on PowerShell, and both produced the same result:
After creating a new flutter program, before editing anyt
You can use flutter clean
command and then try
flutter run
In your terminal
Got a similar error:
The directory ../ does not contain a pubspec.
This is because I was referring to a folder that did not have a pubspec.yaml file.
Solution:
Change from:
file_picker:
path: ../
To
file_picker:
path: ./
For me the culprit was OneDrive. I had to reinstall Windows 10 and when I did, it offered to setup OneDrive for me automatically. I thought - great, one less thing... Then later I realized that it had set itself up with the Files On Demand option set to true. Microsoft never ceases to elicit a facepalm from me with the things they think are great ideas. Just to verify that this was the problem, I copied the entire folder to a temporary location on my hard drive that wasn't synced to OneDrive and it ran fine.
If something has been corrupted in the process of trying to build and run without all the files accessible, hopefully you have a recent commit from github (prior to putting the project on OneDrive) that you can clone. This is assuming your problem has the same cause as mine.
you can find this pubspex.yaml in flutter in following location D:\Mobile-Dev\src\flutter\packages\flutter_tools open CMD change Directory into above location and now you can run flutter upgrades get and other command. This one is working complete fine for me. Hope this will work for you
I saw this error for invalid pubspec.yaml
content, like for example spaces before
name: my_app
like
name: my_app`
In my case, i was using a VS code in Windows 10 and when i created a new project by Flutter: New Project it failed to create the following project files & folders under the project location
android
ios
I tried creating another project and that successfully created with all the necessary files.
Sound dumb but this is what exactly happened to me.
Hope it helps someone.