This package uses the OpenWeatherMAP API to get the current weather status as well as weather forecasts.
weather as a dependency in
For help on adding as a dependency, view the pubspec documenation.
The package uses your location to fetch weather data, therefore location tracking must be enabled.
Add the following entry to your
manifest.xml file, in the Android project of your application:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
In addition, it is recommended to set your minimum SDK version to 21.
info.plistfile in the
Open as > Source Code.
<key>NSLocationWhenInUseUsageDescription</key> <string>This app uses location to forecast the weather.</string> <key>NSLocationAlwaysUsageDescription</key> <string>This app uses location to forecast the weather.</string>
There is an issue with the
location plugin which this package depends on, where an error with the following message
The use of Swift 3 @objc inference in Swift 4 mode is deprecated
may be thrown. For a solution, check the following stack overflow question: https://stackoverflow.com/questions/44379348/the-use-of-swift-3-objc-inference-in-swift-4-mode-is-deprecated
First and foremost you need an API key from OpenWeatherMap, which can be acquired for free here.
WeatherStation weatherStation = new WeatherStation("YOUR_API_KEY");
For api documentation on the current weather API, see the OpenWeatherMap weather API docs.
Weather weather = await weatherStation.getCurrentWeather();
The Temperature class holds a temperature and can output the temperature in Celsius, Fahrenheit, and Kelvin:
double celsius = weather.temperature.celsius; double fahrenheit = weather.temperature.celsius; double kelvin = weather.temperature.kelvin;
For API documentation on the forecast API, see the OpenWeatherMap forecast API docs.
List<Weather> forecasts = await weatherStation.getFiveDayForecast();
Demonstrates how to use the weather plugin.
For help getting started with Flutter, view our online documentation.
Add this to your package's pubspec.yaml file:
dependencies: weather: ^0.1.3
You can install packages from the command line:
$ flutter packages get
Alternatively, your editor might support
flutter packages get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.1.3||Dec 10, 2018|
|0.1.2||Dec 10, 2018|
|0.1.1||Nov 30, 2018|
|0.1.0||Nov 30, 2018|
|0.0.9||Nov 30, 2018|
|0.0.8||Nov 30, 2018|
|0.0.7||Nov 29, 2018|
|0.0.6||Nov 21, 2018|
|0.0.5||Nov 21, 2018|
|0.0.4||Nov 21, 2018|
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
flutter format to format
|Dart SDK||>=2.0.0-dev.68.0 <3.0.0|