Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: How to resolve Error importing package:http/http.dart

Tags:

flutter

dart

I am very new to Flutter, and stuck at the following error:

package:http/http.dart That library is in a package that is not known. 

Maybe you forgot to mention it in your pubspec.yaml file?

Please help in resolving this error.

like image 549
Athar Ansari Avatar asked Nov 24 '18 21:11

Athar Ansari


People also ask

How do I import custom packages in flutter?

Open the Pubspec. yaml file and add the dependency as library name: version number as shown in the figure below. Then it will automatically install your package into your system in either of the above two ways. Now you are pending with just importing the package into the required module.


1 Answers

Go 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 
like image 141
diegoveloper Avatar answered Sep 23 '22 05:09

diegoveloper