Sunday 28 April 2019

error:Flutter http package does not exist

Problem :-

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?

Solution:-

It is clear way to add http to flutter
  1. Add this to your package's pubspec.yaml file:
dependencies:
  http: ^0.12.0
  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

No comments:

Post a Comment

Error While embed the video in Your website page

Error:- Refused to display '<URL>' in a frame because it set 'X-Frame-Options' to 'sameorigin Solution:- if ...