Flutter http package does not exist
It is clear way to add http to flutter
- Add this to your package's pubspec.yaml file:
dependencies: http: ^0.12.0 // latest one might change
- Install it You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter packages get
- Import it Now in your Dart code, you can use:
import 'package:http/http.dart';
If you have done these 3 steps restart your code editor
Did you add it to pubspec
?
dependencies:
flutter:
sdk: flutter
http: 0.12.0
Add:
dependencies:
flutter:
sdk: flutter
http: ^0.12.0
to pubspec.yaml
, update Packages.get
and Packages.upgrade
. If still not working restart the IDE.
In Android Studio import like this
- Go to
pubspec.yaml
- Add dependency
http: ^0.12.0+2
- Click on Packages get at the top
Few important things:
1) Follow the proper indentation while adding the dependency.
Correct:
dependencies:
flutter:
sdk: flutter
http: ^0.12.0+2
Incorrect:
dependencies:
flutter:
sdk: flutter
http: ^0.12.0+2
If you add dependency like this and hit Packages get then,
You will receive the error:
Error on line 21, column 5 of pubspec.yaml: A dependency may only have one source. sdk: flutter
2) Finding package and latest dependency.
You can find the latest HTTP package Here
All the Dart packages are published on Pubsite where you can find and see trending packages.