OpenWeather class

A service class for interacting with the OpenWeather API.

This class provides methods to fetch weather data from the OpenWeather API using the provided API key.

Example usage:

final openWeather = OpenWeather(apiKey: 'your_api_key');

The apiKey parameter is required to authenticate requests to the OpenWeather API.

Constructors

OpenWeather.new({required String apiKey})
Constructor for the OpenWeather class.

Properties

apiKey String
apiKey is used to authenticate the user with OpenWeather API. without proper API key, the other functions throws Exception.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

currentWeatherByCityName({required String cityName, Languages? language, WeatherUnits weatherUnits = WeatherUnits.IMPERIAL}) Future<WeatherData>
Retrieves the WeatherData object by the current city name In order to use the function, cityName is required It is possible to set the weather units by setting a specific value in weatherUnits
currentWeatherByLocation({required double latitude, required double longitude, Languages? language, WeatherUnits weatherUnits = WeatherUnits.IMPERIAL}) Future<WeatherData>
Retrieves the WeatherData object by the current location In order to use the function, latitude and longitude is required It is possible to set the weather units by setting a specific value in weatherUnits
currentWeatherByZipCode({required int zipCode, required String countryCode, Languages? language, WeatherUnits weatherUnits = WeatherUnits.IMPERIAL}) Future<WeatherData>
Retrieves the WeatherData object by ZipCode and Country code In order to use the function, zipCode and countryCode is required It is possible to set the weather units by setting a specific value in weatherUnits
fiveDaysWeatherForecastByCityName({required String cityName, Languages? language, WeatherUnits weatherUnits = WeatherUnits.IMPERIAL}) Future<WeatherForecastData>
Retrieves the weatherForecastData object by the current city name In order to use the function, cityName is required It is possible to set the weather units by setting a specific value in weatherUnits
fiveDaysWeatherForecastByLocation({required double latitude, required double longitude, Languages? language, WeatherUnits weatherUnits = WeatherUnits.IMPERIAL}) Future<WeatherForecastData>
Retrieves the WeatherForecastData object by the current location In order to use the function, latitude and longitude is required It is possible to set the weather units by setting a specific value in weatherUnits
fiveDaysWeatherForecastByZipCode({required int zipCode, required String countryCode, Languages? language, WeatherUnits weatherUnits = WeatherUnits.IMPERIAL}) Future<WeatherForecastData>
Retrieves the WeatherData object by ZipCode and Country code In order to use the function, zipCode and countryCode is required It is possible to set the weather units by setting a specific value in weatherUnits
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited