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 itYou can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter packages get
- Import itNow in your Dart code, you can use:
import 'package:http/http.dart';
If you have done these 3 steps restart your code editor
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.