cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
545 stars 656 forks source link

Weather version 1.2.2 - insecure HTTP is not allowed by platform #192

Closed kevin6shah closed 4 years ago

kevin6shah commented 4 years ago

Device / Emulator and OS

Please complete the following information for each phone and/or emulator you're experiencing this bug on:

NB: Bugs pertaining to old devices/OS versions will likely not be fixed.

Describe the bug

When attempting to use the plugin in flutter, I get an error that says "insecure HTTP is not allowed by platform" along with the insecure (http) link to the openweather api.

So I tried to change the following line in the _buildURL function and my app worked as it should:

String url = 'http://api.openweathermap.org/data/2.5/' + '$tag?';   // Change this
String url = 'https://api.openweathermap.org/data/2.5/' + '$tag?';  // To this

To Reproduce

Just run the following code in the init method of any stateful widget:

WeatherFactory wf = new WeatherFactory(API_KEY_HERE);
Future<List<Weather>> getWeatherInfo() async {
     return await wf.fiveDayForecastByLocation(40.500615, -74.447496);
}
getWeatherInfo()

Expected behavior

Expected to not get an exception here

Actual behavior

Threw an exception as stated above

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, 1.22.0-10.0.pre.338, on Mac OS X 10.15.6 19G2021 x86_64, locale en-US) [✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use flutter config --android-sdk to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2) [!] Android Studio (not installed) [✓] VS Code (version 1.49.1)

[✓] Connected device (1 available)

! Doctor found issues in 2 categories.

thomasnilsson commented 4 years ago

Thanks, corrected this in version 1.2.3 👍