Visual Studio Code - Target of URI doesn't exist 'package:flutter/material.dart'

后端 未结 29 885
Happy的楠姐
Happy的楠姐 2020-12-07 21:33

I\'ve just setup my Macbook for flutter development,

So I downloaded flutter sdk, and placed it in my Documents. After, I setup my path variable to

相关标签:
29条回答
  • 2020-12-07 22:01

    Open the command palette (ctrl+shift+p), type flutter: get packages (should autocomplete); after it resolves open the command palette again and type reload window and execute the command. This should resolve the issue as quickly as possible.

    0 讨论(0)
  • 2020-12-07 22:02

    If you have used the flutter packages get command and the error still persists, you can simply reload VS code the Developer: Reload Window command. Simply type that in after pressing Ctrl+Shift+P (Cmd+Shift+P for Mac users). It will clear the error. It's like refreshing VS Code.

    0 讨论(0)
  • 2020-12-07 22:02

    Warning! This package referenced a Flutter repository via the .packages file that is no longer available. The repository from which the 'flutter' tool is currently executing will be used instead.
    running Flutter tool: /opt/flutter previous reference : /Users/Shared/Library/flutter This can happen if you deleted or moved your copy of the Flutter repository, or if it was on a volume that is no longer mounted or has been mounted at a different location. Please check your system path to verify that you are running the expected version (run 'flutter --version' to see which flutter is on your path).

    Checking the output of the flutter packages get reveals that the reason in my case was due to moving the flutter sdk.

    0 讨论(0)
  • 2020-12-07 22:05

    I was trying use the audio players flutter package. Once I added it to pubspec.yaml and tried to import it to main.dart, I got the same error.

    I tried to restart my IDE but that didn't help so i tried running flutter packages pub cache repair and it worked.

    0 讨论(0)
  • 2020-12-07 22:06

    Basically

    1. Check for correct indentation of your package in dependencies
    2. if your editor supports, it automatically runs -> flutter pub get
    3. Either way -> open terminal-> flutter pub get or flutter packages get
    4. check .packages file, see if your package is present else reinstall package
    5. Most important : Restart your IDE (Visual studio or Android Studio)

    Start debugging your project

    Most probably , your errors will be fixed by then

    Hope it works for you

    0 讨论(0)
  • 2020-12-07 22:06

    If you change the property name in pubspect.yaml all your package in lib folder turn to red with the error Target of URI doesn't exist...

    0 讨论(0)
提交回复
热议问题