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 inweatherUnits
-
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
andlongitude
is required It is possible to set the weather units by setting a specific value inweatherUnits
-
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
andcountryCode
is required It is possible to set the weather units by setting a specific value inweatherUnits
-
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 inweatherUnits
-
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
andlongitude
is required It is possible to set the weather units by setting a specific value inweatherUnits
-
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
andcountryCode
is required It is possible to set the weather units by setting a specific value inweatherUnits
-
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