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



Solution 1:[1]

  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.

Solution 2:[2]

I tried this solution and it worked just perfect:

open terminal from the project directory and run

flutter packages get

Solution 3:[3]

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.

Solution 4:[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.

Solution 5:[5]

This error occurs mostly when moving the project from one computer to another, this may happen, that the packages are not taken into

Regenerate the package to solve this, here is the step

  1. Deleting pubspeck.lock
  2. Then run flutter pub get

Sometimes, this issue is resolved simply by running flutter pub get once again...

Solution 6:[6]

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.

Solution 7:[7]

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

Solution 8:[8]

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

Solution 9:[9]

Add the following to the pubspec.yaml

environment:
  sdk: '>=2.10.0 <3.0.0'

and then run flutter pub get.

Solution 10:[10]

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

flutter packages get

Solution 11:[11]

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.