getWeather method Null safety

Future<OpenWeather?> getWeather(
  1. {String units = "metric",
  2. required double lat,
  3. required double lon,
  4. String lang = "en"}
)

Implementation

Future<OpenWeather?> getWeather({
  String units = "metric",
  required double lat,
  required double lon,
  String lang = "en",
}) async {
  final response = await get("weather", params: {
    "appid": weatherKey,
    "lat": lat.toString(),
    "lon": lon.toString(),
    "lang": lang,
    "units": "metric",
    "mode": "json",
  });
  if (response != null) {
    return OpenWeather.fromJson(response);
  } else {
    return null;
  }
}