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

后端 未结 29 889
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:08

    I was following the Flutter get started tutorial and VSCode could not find the package for english_words, despite it showing in pubspeck.lock and .packages. Hot reload didn't work.

    To make it work, I stopped the instance and re-run it - so I didn't have to restart VSCode.

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

    I was using (goggle location picker (with much more customisation in functions and UI) ) so I copy this package(complete) and using in my app in one folder but since dart code analyser analyses one flutter project so I found that those which are referencing from inside of this package is not working then I copy only lib folder(of google location picker) in my original project folder and voila this worked for me. This solution took me a time of 3 days. I know this is not the question but it might help someone to save 3 days.

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

    This worked for me in Android Studio as well as VS Code. I only had to run these lines in my terminal/command prompt and problem was solved. There was no need to restart any of the IDEs again

    • flutter packages get

    Optionally you also run.

    • flutter upgrade
    0 讨论(0)
  • 2020-12-07 22:09

    Don't forget to save pubspec.yaml before running "flutter pub get". Restarting Visual Studio Code is not enough. That was my solution. Sometimes when you work with intellij you forget that ...

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

    I also had this issue. I had both VS code and Android studio installed in my system.

    The error was in VS code.

    When i opened the same project on Android studio, the dependency was not actually added to pubsec.yaml. I added it there and ran pub.get.

    When I returned to VS Code and everything was working fine.

    So, Try opening it in other editor if you have, or through NotePad.

    Edit:

    Opening widget_test.dart and running it should also solve your issue.

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

    Execute one of the following:

    • flutter upgrade

    • flutter pub get

    • flutter packages get

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