fromHour static method
Get a 'time' IconData at a specific hour
.
If hour
is midnight (0) then it will return WeatherICons.time_12
.
If hour
is not within 0-24 then a UnsupportedError will be thrown.
Implementation
static IconData fromHour(int hour) {
if (hour < 0 || hour > 24) {
throw UnsupportedError('Unsupported hour $hour');
}
if (hour == 0) {
return WeatherIcons.time_12;
}
final convertedHour = hour > 12 ? hour - 12 : hour;
return all[convertedHour - 1];
}