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
Just add dependencies: http: ^0.12.0 in pubspec.yaml file please check http documentation
try to run flutter clean
then restart VS Code. This did it for me.
Add dependencies.
for example:- import 'package:audioplayers/audio_cache.dart';
in the above package if we only use this package then it shows error
but if we add dependencies in pubspec.yaml
such as
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
audioplayers: ^0.14.1
then click on packages get.
as you see this, I can also insert dependencies so if you insert dependencies along with your package then you are good to go.
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:
Author of the Dart Code plugin here! From the screenshot, I would say this is because your flutter project is in a sub-folder of the folder open in Code. We only scan the opened-folder to check whether it's a Flutter project - which then changes the SDK we launch and also enables the Flutter functionality (like the daemon and debugger).
You should re-open the "todo" folder directly.
If you want to have multiple projects open together, use multi-root workspaces, since Dart Code is multi-root-aware and will check each of the folders in the workspace when deciding if it needs to enable Flutter functionality.
This case should be better supported in the Dart plugin now, so opening the immediate parent folder of a Flutter project should work as expected.
If you execute From the terminal: "Run flutter packages get" and the error continues, check is all packages directories are listed at '.packages' file. - Sometime you have the packages, but it is not configured at this file.