weather 0.0.7 copy "weather: ^0.0.7" to clipboard
weather: ^0.0.7 copied to clipboard

outdated

A weather plugin for fetching current weather and forecasting via the OpenWeatherMap API. Works for both Android and iOS.

weather #

pub package

Install #

Add weather as a dependency in pubspec.yaml. For help on adding as a dependency, view the documentation.

Permissions #

The plugin uses your location to fetch weather data, therefore location tracking must be enabled.

Android #

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.

iOS #

  1. Open the XCode project of your app, named Runner.xcodeproj
  2. Locate the info.plist file in the Runner directory.
  3. Right click info.plist and choose Open as > Source Code.
  4. Add the following entries inside the <dict></dict> tags`:
<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>

Usage #

First and foremost you need an API key from OpenWeatherMap, which can be acquired for free here.

String key = 'YOUR_API_KEY';
Weather weather = new Weather(key);

Query current weather #

For api documentation on the current weather API, see the documentation.

Map<String, dynamic> weatherJSON = await weather.getCurrentWeather();

Query 5 day forecast #

For api documentation on the forecast API, see the documentation.

Map<String, dynamic> forecastJSON = await weather.getFiveDayForecast();
222
likes
0
pub points
96%
popularity

Publisher

verified publishercachet.dk

A weather plugin for fetching current weather and forecasting via the OpenWeatherMap API. Works for both Android and iOS.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http, location

More

Packages that depend on weather