Flutter http package does not exist

It is clear way to add http to flutter

  1. Add this to your package's pubspec.yaml file:
dependencies:
  http: ^0.12.0 // latest one might change
  1. Install it You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

  1. 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

  1. Go to pubspec.yaml
  2. Add dependency http: ^0.12.0+2
  3. Click on Packages get at the top

enter image description here

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. enter image description here

Tags:

Http

Dart

Flutter