weatherHistory method

Future<WeatherForecast?> weatherHistory({
  1. required DateTime date,
  2. double? lat,
  3. double? lng,
  4. String? location,
})

Implementation

Future<WeatherForecast?> weatherHistory(
    {required DateTime date,
    double? lat,
    double? lng,
    String? location}) async {
  Map<String, dynamic> params = {
    'key': WEATHER_API_KEY,
    'dt': date.formatDate(formatType: 'yyyy-MM-dd'),
    '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.weatherHistory(params);
  return response.data;
}