0

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 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Declaration code

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.