22

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.

Farah Bédoui
  • 863
  • 2
  • 7
  • 8

11 Answers11

33
  1. ctrl -> Shift -> A (Find Action)
  2. Search for "Dart Analysis"
  3. Click the icon that says "Restart the Dart Analysis server"
  4. The red underline disappears from the package import and everything works.
Mohamed Mesalm
  • 704
  • 8
  • 17
17

I tried this solution and it worked just perfect:

open terminal from the project directory and run

flutter packages get
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
Adel Bashaibah
  • 179
  • 1
  • 3
7

Flutter Issue Fix: 18-April-2020

It happened due to :

  1. You have created a project and then you try to push the code to Git ( and keeping your vscode open)
  2. Your package needs to update using command flutter packages get ( simply from vscode menu choose terminal and then run this command )
  3. If you still it didn't fix your issue, simply go to File Menu, choose Close Folder, it fixes your issue.
  4. Last option restart VSCode.
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Shobhakar Tiwari
  • 7,862
  • 4
  • 36
  • 71
4

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.

Igbokwenu
  • 51
  • 3
2

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.

1

Taking a look into Flutters Github Issues there can be many causes.

  1. Your git causes this error (issue 19384)

Just delete every entry in your projects .gitignore on your maschine.

  1. 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.

Marcel Hofgesang
  • 951
  • 1
  • 15
  • 36
  • This one, combined with the proposed VSCode restart from here, worked for me: https://stackoverflow.com/questions/44909653/visual-studio-code-target-of-uri-doesnt-exist-packageflutter-material-dart – Watth Aug 31 '20 at 12:55
1

I only re-save my old file. Then restart VSCode.

0

I had to delete flutter folder and reinstall it from scratch...

marcolav
  • 405
  • 1
  • 6
  • 17
0

For me, I needed to remove : colons from the app description in the pubspec.yaml file, and run

flutter packages get
desertnaut
  • 57,590
  • 26
  • 140
  • 166
0

Add the following to the pubspec.yaml

environment:
  sdk: '>=2.10.0 <3.0.0'

and then run flutter pub get.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Yigit Alparslan
  • 1,377
  • 1
  • 8
  • 13
0

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.