weatherForecast method

Future<WeatherForecast?> weatherForecast({
  1. double? lat,
  2. double? lng,
  3. String? location,
})

Implementation

Future<WeatherForecast?> weatherForecast(
    {double? lat, double? lng, String? location}) async {
  Map<String, dynamic> params = {
    'key': WEATHER_API_KEY,
    'days': 10,
    'aqi': 'no',
    'alerts': 'no'
  };
  if (location != null && location.trim().isNotEmpty) {
    params.addAll({'q': location});
  } else if (lat != null && lng != null) {
    params.addAll({'q': '$lat,$lng'});
  }
  NetworkResponse response = await _api.weatherForecast(params);
  return response.data;
}