@@ -118,20 +118,25 @@ WeatherType getWeatherType(WeatherData weatherData) {
118118 ).hour;
119119 final night = hour > 20 || hour < 6 ;
120120
121- switch (weatherData.shortDescription) {
122- case 'Clouds' :
123- return night ? WeatherType .cloudyNight : WeatherType .cloudy;
124- case 'Drizzle' :
125- return WeatherType .lightRainy;
126- case 'Rain' :
127- return WeatherType .heavyRainy;
128- case 'Snow' :
129- return WeatherType .heavySnow;
130- case 'Clear' :
131- return night ? WeatherType .sunnyNight : WeatherType .sunny;
132- case 'Sunny' :
133- return night ? WeatherType .sunnyNight : WeatherType .sunny;
134- default :
135- return WeatherType .thunder;
136- }
121+ return switch (weatherData.longDescription) {
122+ 'overcast clouds' => night ? WeatherType .cloudyNight : WeatherType .cloudy,
123+ 'scattered clouds' => night ? WeatherType .cloudyNight : WeatherType .cloudy,
124+ 'broken clouds' => night ? WeatherType .cloudyNight : WeatherType .cloudy,
125+ 'few clouds' => night ? WeatherType .cloudyNight : WeatherType .cloudy,
126+ 'light rain' => WeatherType .lightRainy,
127+ 'heavy rain' => WeatherType .heavyRainy,
128+ 'light snow' => WeatherType .lightSnow,
129+ 'heavy snow' => WeatherType .heavySnow,
130+ 'clear sky' => night ? WeatherType .sunnyNight : WeatherType .sunny,
131+ _ => switch (weatherData.shortDescription) {
132+ 'Clouds' => night ? WeatherType .cloudyNight : WeatherType .cloudy,
133+ 'Drizzle' => WeatherType .lightRainy,
134+ 'Rain' => WeatherType .middleRainy,
135+ 'Snow' => WeatherType .heavySnow,
136+ 'Clear' => night ? WeatherType .sunnyNight : WeatherType .sunny,
137+ 'Sunny' => night ? WeatherType .sunnyNight : WeatherType .sunny,
138+ 'Wind' => night ? WeatherType .dusty : WeatherType .dusty,
139+ _ => WeatherType .thunder
140+ }
141+ };
137142}
0 commit comments