Cannot Create Flutter Project in Android Studio due to missing pubspec.yaml - flutter

Whenever I create the Create new Flutter Project in android studio,
It's always throwing out this error: Please help.
Could not find a file named "pubspec.yaml" in "/Users/<usrname>/AndroidStudioProjects/inventory_system". pub get failed (66; Could not find a file named "pubspec.yaml" in "/Users/<usrname>/AndroidStudioProjects/inventory_system".)

First of all make sure your flutter is properly installed on your system. Faced the same issue. Try checking your installation and make sure everything is installed properly. Use this link: https://flutter.dev/docs/get-started/install
Just uninstall android as well as flutter. Try installing them again. First download and install Flutter. Then download and install Android Studio. Follow the proper installation process. I guess your issue is because of the unproper installation.
After flutter installation, open the folder where you have installed it, and open the file flutter_console which is a batch . It will open a console and then type:
flutter doctor
This will show you whether all the installation is properly carried out or not. But a better way is to perform proper installation.
Also you need to set environment variable after the installation.
Here is what happened with me when I installed flutter and android. This is just to show you the issue I had faced after installation
I then followed what was been said as error and got my flutter and android studio working.

Open the terminal.
Create the folder for your project by typing the command:
mkdir my_awesome_project
Navigate to the created folder:
cd my_awesome_project
In the folder type the command for project creation:
flutter create myawesomeproject
Open the AndroidStudio and then open the created folder.
Now you are ready to run and develop your app.

the easiest and simplest way to create new flutter project is to add flutter plugin to android studio/vs code and selecting SDK dir and then you can simply create new flutter project by clicking on buttons
and you can check flutter official guide

Related

Android studio has several problems regarding Flutter

I am new in android studio and flutter and I have encountered several problems after installing them. I already went to flutter doctor and it's all checked so flutter isn't the problem. I can't start coding because of these problems:
Here the sample code made by flutter itself I can't run it has several errors and
Here I can't run any virtual device because it says that I don't have an internet connection which is not true. I cannot code if I can't run the sample dummy code.
Thanks
I think you haven't properly done the setup for Android Studio. Please check the documentation where you will get steps for proper installation.
Few things which you can check:
Flutter and Dart plugins should be installed in Android Studio
If you want to run on an emulator, you will have to download the image for it whose answer you can find in previous answers.
When you first open Android Studio, you should get an option to create a Flutter Application.
Try to reinstall android studio with stable internet connection.
i would advise you to follow below steps to download system images to create virtual device
Select sdk manager
Download a system image by selecting show package details.You can download api32 system images which is the latest for now.
Once downloaded you can see the image file while created avd.
Some errors i got and how i fixed it
(ERROR 1) [flutter] flutter doctor -v 'crumb' is not recognized as an internal or external command, operable program or batch file. Error: Unable to find git in your PATH. exit code 1
(FIX) Go to flutter installation folder and inside flutter/bin edit the flutter.bat file using a text editor and remove the line (20) that says
IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path%
The code should look like this on those lines
REM If available, add location of bundled mingit to PATH
SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd
Save and Run flutter doctor and everything should work fine.
(ERROR 2) flutter doctor takes too long
(fix) I downloaded the previous version of the sdk it worked like a charm
(ERROR 3) Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.
(fix) Open Android Studio
Tools Menu, SDK Manager
In the window that comes up there are inner panels, choose SDK Tools panel
Tick Android SDK Command-line Tools
Choose Apply button near the bottom of the window
This worked
(ERROR 4) `The term 'flutter' is not recognized as the name of a cmdlet, function, script file, or operable program.
(fix) put the correct part in the env variables like i had put D:\flutter insted of D:\flutter\bin that worked

Can not install Flutter on MacOs, Tells that the unzip process is not working

When I try to install
unzip ~/Downloads/flutter_macos_2.2.2-stable.zip
this message pops up
unzip: cannot find or open /Users/user/Downloads/flutter_macos_2.2.2-stable.zip, /Users/user/Downloads/flutter_macos_2.2.2-stable.zip.zip or /Users/user/Downloads/flutter_macos_2.2.2-stable.zip.ZIP.
I don't what to do to install Flutter to OSX (vscode)
I can obtain flutter for Android Studio with no problems.
Also can't access flutter by itself on iTerm or Terminal.
First, it seems that your archive has two extensions .zip.zip, but it's probably not the problem you're facing.
You may want to check if your iTerm has the necessary permissions to access the content of the folder "Download" since it's a special folder for MacOS.
Second, for creating a flutter project through VSCode, you need to run the command flutter create myprojectnamehere, you will not have a button to create a flutter project like on Android Studio.
If you still facing issues with the installation of Flutter, you may want to checkout Flutter_Installer which is a Flutter GUI Installer made with Flutter.

Flutter new web project not showing in Visual Studio command palette

I have installed Visual Studio Code, Dart and Flutter correctly according to the tutorial step shown in docs. I have checked it 100 times but nothing is wrong, unable to find issue.
Expected result in Flutter:
New web project must be visible in in Visual Studio Code.
I was not able to get 'Flutter: New Web Project", but following https://flutter.dev/docs/get-started/web from the Flutter Docs got me running the app on the web. Hope it helps. Below are the commands that I entered in Visual Studio Code's terminal
$ flutter channel dev
$ flutter upgrade
$ flutter config --enable-web
$ mkdir <new_project_directory_name>
$ cd <into new_project_directory>
$ flutter create .
$ flutter run -d chrome
Flutter: New Web Project was removed from the VS Code extension. The excuse was this was always supposed to be temporary and it broke with the latest release of 'Stagehand'. But removing it makes it harder to create a new web project. I followed the directions given in answer by #ALotLikeEss.
I tried this and it's working for me :
open terminal in project folder and execute this :
flutter config --enable-web
And restart your IDE
Run commando in terminal flutter config --enable-web, restart your vscode or android studio and try again..
I had the same problem. if flutter plugin is installed, direct visual studio code to a folder (open a folder) then select view>command palette> or press ctrl+shift+p short cut keys, then write flutter. Flutter:New Project item will be displayed. Opening a folder solved my problem.
Simply select "Debug" and "Start Debugging" from the menu. After this, the command palette will appear.
Update your visual studio code to latest version (Version 1.35.0 (1.35.0)) and install Flutter and Dart plugin

Setting up Flutter with Visual Studio Code

I am a C# developer, but have been tasked with developing a Flutter app, and I am discovering I have no idea what I am doing. I have a copy of Visual Studio Code and have installed the Flutter SDK, but they aren't working together. The Dart and Flutter extensions are installed, but when I CTRL+SHIFT P and select Flutter: New Project, the prompt disappears and I find myself with nothing changed on the screen. Earlier, I was getting an error that VSCode could not find my SDK.
I am going nuts. Can someone tell me where to start debugging this problem?
Seems that you don't have the SDK installed.
Navigate to the View option on vs code then select Command Palette.
type the word flutter in the palette; it should give you a list of commands, for
instance, creating a new project and flutter doctor.
Select either Flutter: Run flutter doctor of Flutter: run new project
You will get an option at the bottom|right side of vs code to select installation folder for SDK (if you don't have it). You will then be prompted with Project name and location.
To run your sample project, you can use flutter run command.
VS Studio is looking for flutter in predefined folders as indicated in the "View Logs" button. To fix this, Add the flutter\bin folder in your environment variable.
In Windows, right-click "This PC" -> "Properties" -> "Advanced System Settings" -> In "Advanced" Tab, click on "Environment Variables", In "System Variables" section select "Path"
Next click "Edit", click "New" and put the location of the bin folder where flutter is installed.
Restart VS Studio, and re-run flutter doctor.
If you're running Flutter: New Project and then seeing nothing at all, then this is certainly a bug in the extension. It's supposed to prompt you for a project name and location.
If you can still reproduce this, please raise a bug on GitHub and if possible attach an Extension log. There may also be useful information in the dev console (Help -> Toggle Developer Tools).
Flutter setup for VSCode windows
You Need to download flutter libraries either from flutter or git
a. From flutter
https://storage.googleapis.com/flutter_infra/releases/stable/windows/flutter_windows_v1.12.13+hotfix.9-stable.zip
b. From git clone (make sure git is installed in your system)
C:\src>git clone https://github.com/flutter/flutter.git -b stable
Extract or clone flutter libraries in following directory
C:\flutter
Add a new environment veritable path C:\flutter\bin
Run flutter version to check flutter installed correctly
Install VSCode
Install Flutter and Dark extensions in VSCode
Press Ctrl + Shift + P to open command palette. Type in the search bar Flutter and click on Flutter: New Project.
It will create a demo project.
Run flutter to run demo project
Note - You may need to install android studio as it will set android SDK and emulator

Target of URI doesn't exist 'package:flutter/material.dart'

My Flutter IDE (Android Studio) doesn't recognize material.dart anymore! It happened suddenly, I was working normally then my PC turned off because of CPU 100% consumption and when I restarted I found this problem.
ctrl -> Shift -> A (Find Action)
Search for "Dart Analysis"
Click the icon that says "Restart the Dart Analysis server"
The red underline disappears from the package import and everything works.
I tried this solution and it worked just perfect:
open terminal from the project directory
and run
flutter packages get
Flutter Issue Fix: 18-April-2020
It happened due to :
You have created a project and then you try to push the code to Git ( and keeping your vscode open)
Your package needs to update using command flutter packages get ( simply from vscode menu choose terminal and then run this command )
If you still it didn't fix your issue, simply go to File Menu, choose Close Folder, it fixes your issue.
Last option restart VSCode.
Solution that worked for me: inside your pubspec.yaml file, make sure that the name field (it's the first line of your pubspec.yaml file) has the correct name of the project. If it doesn't, change it and run pub get.
Check bupspec.yaml file. Something may be removed from there. I had the same issue and found out this problem and it's fixed now.
Taking a look into Flutters Github Issues there can be many causes.
Your git causes this error (issue 19384)
Just delete every entry in your projects .gitignore on your maschine.
There are some missing flutter packages (issue 17016)
Even when you've just installed flutter yet it can occur that some packages are going to be missed.
Going to the root of your Flutter project via command prompt and typing the command flutter packages get will fix this.
I only re-save my old file. Then restart VSCode.
I had to delete flutter folder and reinstall it from scratch...
Add the following to the pubspec.yaml
environment:
sdk: '>=2.10.0 <3.0.0'
and then run
flutter pub get.
For me, I needed to remove : colons from the app description in the pubspec.yaml file, and run
flutter packages get
This can also happen if you delete manually delete flutter package from Dart packages. The solution in this case is to reinstall flutter SDK by erasing current User/flutter folder and downloading a new one. Then run flutter packages get and you should see all dependencies in place.