Flutter doesn't recognize valid imports - flutter

This just started happening randomly. The app runs fine, but most valid imports are not recognized. This is happening with packages and local files.
I've restarted and Android Studio, did a pub cache repair, flutter clean, uninstalled and reinstalled the android studio flutter plugin, tried opening in VScode, nothing is helping.
Other people on my team have pulled my same repo and they are not experiencing this problem.
Any Ideas?

Most of the issue should be resolved by android studio "invalidate cache and restart" action.

I faced to this problem and restarted Android Studio some times and it continue still not working. So, I changed the name of import and putted just the name of the file. Example: import 'authentication.dart'. Without the whole 'package:.../'.
If you're importing packages, try this in the terminal (same directory of the project):
with pub:
$ pub get
with flutter:
$ flutter pub get

Its work for me
Bottom Menu -> Dart Analysis -> Restart Dart Analysis Server
OR try
flutter pub get
Until recognize valid imports

Related

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

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

flutter error Could not find an option named "platforms"

I'm new to learning flutter when I try to crate a new project on android studio gives me a arror message in the event section enter image description here
The MESSAGE: [Could not find an option named "platforms". Run 'flutter -h' (or 'flutter -h') for available flutter commands and options.]
And another problem is flutter doctor does not see the android studio enter image description here
1(By the way, I want to use this version of flutter, please do not give a suggestion like update.)
2(this problem did not exist before, it happened after turning my computer off and on)
And sorry for my english mistakes
Thank you.
flutter version flutter_windows_v1.12.13+hotfix.9-stable
andorid studio version: 4.1.3
Is this the answer to your question about andorid studio?
and you need to install JDK
You are using the wrong flutter SDK. Too low information in your question. Make sure that you have the right path to flutter SDK in your IDE. Check that the flutter SDK directory has the appropriate structure, all needed files and cetera. Channel and version of flutter also may have an influence on this problem.
Got this today out of nowhere. Things were going well, but suddenly when I tried to relaunch the app from fresh, for the error Could not find an option named "target"
UPDATE:
This appears to happen when I switch branches and merge while app is running/flutter is attached. If you're using VS Code,
open your launch.json
change something, I decided to change type: "dart" to type: "notdart"
save
try to debug which fails
then revert that change.
This should fix the issue.
Previous Answer/If you're not using VS Code
What worked for me was to
flutter clean
close the editor (VS Code for me)
close the emulator
give a minute for things to close down
open task manager and kill any left over processes of dart.exe flutter.exe and java.exe and adb.exe (was doing Android)
start VS Code/Android Studio and try to debug again. (when prompted I chose to cold boot the emulator as well)
This takes a while as the emulator has to cold boot and since flutter clean was run, the compilation hadto start from scratch as well.

Running Pub Upgrade in flutter installation taking too much time

I have a serious issue trying to install flutter... The pub upgrade when you run flutter doctor have being running for the past one hour on my system... I have being stuck with this issue since yesterday i don't know what the exact problem is... I have tried installing via Android Studio and through command line... It ends up getting stuck at "Running Pub Upgrade"...
Here are a few things you can try,
Close Android studio,
Open Task Manager and see if any Dart/Flutter services are running, if yes then close them.
Clear cache from flutter/bin folder.
and now run again.
I was a able to solve this problem, by downloading the flutter zip file in the flutter website, adding flutter/bin directory to my environment variables Path, restarting my system and running flutter doctor...
I also encountered the same problem, but I solved it using another computer,
what I did was;
I cleared my cache folder in flutter/bin folder
then I copied the folder containing flutter SDK into another computer *C:* drive so the folder was like C:\src\flutter on the other computer(which was windows also), opened the folder, opened flutter console, and run flutter doctor. it worked fine on that computer, everything was in place, so I copied that same folder again back into my computer, replacing all exiting files and run flutter doctor on my computer and it worked for me.
I also had this problem. It was stuck on "Running pub upgrade..." for more than 24 hours.
On this GitHub thread someone solved it by turning Anti-virus shields off. [https://github.com/flutter/flutter/issues/61719][1] (Stuck at Running pub upgrade)
This solved the issue for me. I closed Windows PowerShell, and turned off Avast Anti-virus shields. I re-opened Windows PowerShell, ran flutter doctor and all went through perfectly with no issues.

New flutter package not worknig

pls help me out i'v tried everything. i did
flutter clean
flutter packages get
flutter packages upgrade
Restart Visual Studio (by using command: reload window)
take a look, my import package is not working...this is the image:
sorry, i already figure out myself. when a package is not working run the commands i provide, and then open your app (the app you are programming... well hit run). this will make VSCODE start actually running the commands and will run the {flutter pub get}. Try it out!
have a great one :)!

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.