Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter http package does not exist

Tags:

http

flutter

dart

normally the package should be imported like this:

import 'package:http/http.dart' as http;

but now I get this error:

[dart] Target of URI doesn't exist: 'package:http/http.dart'. [uri_does_not_exist]

did it somehow changed in the new updates of Flutter? if so, how can I perform a get request now?

like image 853
nimzz Avatar asked Oct 13 '22 17:10

nimzz


2 Answers

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

like image 112
Bawantha Avatar answered Oct 17 '22 19:10

Bawantha


Did you add it to pubspec?

dependencies:
  flutter:
    sdk: flutter

  http: 0.12.0
like image 27
Andrey Turkovsky Avatar answered Oct 17 '22 18:10

Andrey Turkovsky