0
votes

I'm trying to add http package to my sample flutter project. However, it constantly fails.

It gives the following o/p

>[sample_hello_world] flutter packages get
>Running "flutter packages get" in sample_hello_world...             1.3s
>exit code 0
>[sample_hello_world] flutter packages get
>Running "flutter packages get" in sample_hello_world...             1.1s
>exit code 0
>[sample_hello_world] flutter packages get
>Running "flutter packages get" in sample_hello_world...             0.8s
>exit code 0

This is my pubspec.yaml

name: sample_hello_world description: A new Flutter project. version: 1.0.0+1

environment: sdk: ">=2.1.0 <3.0.0"

dependencies: flutter: sdk: flutter

cupertino_icons: ^0.1.2 shared_preferences: ^0.4.2 http: ^0.12.0

dev_dependencies: flutter_test: sdk: flutter

flutter: uses-material-design: true assets: - assets/login_icon.png

Any ideas, i/p will be appreciated.

I have tried different networks, checked for unwanted proxies. Can't get to know what is. I wrote and then tapped on the Get Packages button in Visual Studio IDE, but it never seems to load the packageenter image description here

3

3 Answers

1
votes

Install this instead :

dependencies:
  http: ^0.12.0+2

That's it , there is not an error or something, to test if everything is set up , maka a dart file , and import this :

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

if it shows that it's an unused package , that means that everything works fine.

0
votes

I declare http dependence in this way. Remember to take care of your indentation

Declaration code

0
votes

I have the exact same problem with this. Helped relaunching Android Studio and installing again.