backgroundWeatherTheme function Null safety

ThemeWeather backgroundWeatherTheme(
  1. BuildContext context
)

Implementation

ThemeWeather backgroundWeatherTheme(BuildContext context) {
  var now = unixToDateTime(WeatherProvider.read(context).openWeather?.dt) ?? DateTime.now();
  if (now.hour >= 0 && now.hour < 5) return ThemeWeather(evening, evening.colors.first);
  if (now.hour >= 5 && now.hour < 7) return ThemeWeather(beforeSunRise, evening.colors.first);
  if (now.hour >= 7 && now.hour < 11) return ThemeWeather(dawn, evening.colors.first);
  if (now.hour >= 11 && now.hour < 17) return ThemeWeather(day, evening.colors.first);
  if (now.hour >= 17 && now.hour < 19) return ThemeWeather(candleLight, evening.colors.first);
  if (now.hour >= 20 && now.hour < 24) return ThemeWeather(evening, evening.colors.first);
  return ThemeWeather(day, day.colors.first);
}