currentWeatherByCityName method
Future<WeatherData>
currentWeatherByCityName({
- required String cityName,
- Languages? language,
- WeatherUnits weatherUnits = WeatherUnits.IMPERIAL,
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
Implementation
Future<WeatherData> currentWeatherByCityName(
{required String cityName,
final Languages? language,
WeatherUnits weatherUnits = WeatherUnits.IMPERIAL}) async {
try {
Map<String, dynamic> currentWeather = await _sendRequest('weather',
cityName: cityName, weatherUnits: weatherUnits, language: language);
return WeatherData.fromJson(currentWeather);
} catch (err) {
rethrow;
}
}