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

后端 未结 29 894
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:14

    When you usually get this error message:

    Target of URI doesn't exist: 'package:foo'. Try creating the file referenced by the URI, or Try using a URI for a file that does exist.

    Example:

    Target of URI doesn't exist: 'package:random_string/random_string.dart'. Try creating the file referenced by the URI, or Try using a URI for a file that does exist.

    import 'package:random_string/random_string.dart';
    

    It is because a dependency is missing.

    So all you have to do is find out what packages are needed by googling your package name.

    Install the dependency:

    $ flutter pub get
    

    and add the dependency in the pubspec.yaml file:

提交回复
热议问题