A composable, Future-based library for making HTTP requests. It is easy to retrieve and upload JSON via a REST-based web service. So in this article, we will go through the How to Resolve Error Importing package:http/http.dart In Flutter.
How to Resolve Error Importing package:http/http.dart In Flutter??
So now lets start with, Going to your pubspec.yaml file, and add the HTTP dependency:
dependencies: flutter: sdk: flutter cupertino_icons: ^0.1.2 http: any
Remember, the indentation must be the same as ‘flutter’ or ‘cupertino_icons‘. And don’t forget to run this command in your terminal:
flutter packages get
So You will just have to add the latest HTTP dependencies in pubspec.yaml
dependencies: flutter: sdk: flutter http: ^0.12.0+1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2
Don’t forget to change version number of HTTP To check the latest version of HTTP Click here
If you are running the app directly from the command line then you could also do it with flutter:
$ flutter packages get
$ pub get
1. Add this to your package’s pubspec.yaml file:
dependencies: http: ^0.12.1
2. Install it :
$ flutter pub get
3. Now in your Dart code, you can use:
import 'package:http/http.dart' as http;
Let us know what methods you have used in the past for the same problem !!
So in this article, We have been through the How to Resolve Error Importing package: HTTP/HTTP.dart In Flutter.
If you are still confused about Flutter Development, Just let us know. we would love to assist you.
Hope you like this article. Stay connected 🙂
Do not forget to share your valuable suggestions/feedback right below in the comments.
Flutter Agency is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget Guide, Flutter Projects, Code libs and etc.
Flutter Agency is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.