3
votes

When trying to import http package I can see the red underlining as it is error.

In terminal I tried running "flutter clean" and then adding "http: ^0.12.0" to pubspeck.yaml and running "flutter packages get" but it shows: "Could not resolve URL "https://pub.dartlang.org". pub get failed (69)"

Packages like "flutter/material.dart" are correctly imported. Don't know what to do.

Could this be issue with http not being back-compatible with flutter 1.0?

4
Sounds like you are behind a proxy which is not properly configured. See also github.com/dart-lang/sdk/issues/21316, github.com/flutter/flutter/wiki/Using-Flutter-in-China - Günter Zöchbauer
I think I am behind proxy, but flutter doesn't include option to overcome this, right? In python, for example, you can "pip install --proxy ... ". - micchikk
Flutter uses environment variables as explained in the link above. If you are not in china you can use the normal URL for PUB_HOSTED_URL (pub.dartlang.org). - Günter Zöchbauer
I just checked the china link, sorry. I'll try this and let you know. - micchikk
OK, I resolved the problem, thank you :) - micchikk

4 Answers

4
votes

So the problem was I was behind proxy and added enviromental variables (https_proxy) as strings in quotation marks, where they should be added without " ". More here (https://www.dartlang.org/tools/pub/troubleshoot).

4
votes

On Linux/macOS:

$ export https_proxy=hostname:port

On Windows Command Prompt:

$ set https_proxy=hostname:port

On Windows PowerShell:

$ $Env:https_proxy="hostname:port"

If the proxy requires credentials, you can set them as follows.

On Linux/macOS:

$ export https_proxy=username:password@hostname:port

On Windows Command Prompt:

$ set https_proxy=username:password@hostname:port

On Windows PowerShell:

$ $Env:https_proxy="username:password@hostname:port"

For more information refer this link

0
votes

This usually happens when you are behind proxy. To see what proxy it is using use following commands on Mac -> Terminal

echo $ALL_PROXY or echo $https_proxy

Set appropriate proxy using -

export https_proxy="https://<username>:<password>@<proxy>:<port>"

There will be a strange problem here though, if your password contains "@" then you can either try to replace it with special character %40 or worst case change your password to something with _.

-1
votes

Connect to V_P_N(Cisco) and check again.