stringToTimeOfDay static method
convert time (String to TimeOfDay)
Implementation
static TimeOfDay stringToTimeOfDay({required String? time}) {
try {
if (_isNullOrEmpty(time)) {
return TimeOfDay.now();
} else {
int hour = TimeOfDay.now().hour;
int minute = TimeOfDay.now().minute;
List<String> timeArray = time!.split(":");
if (timeArray.length > 1) {
hour = int.parse(timeArray[0]);
minute = int.parse(timeArray[1]);
}
return TimeOfDay(hour: hour, minute: minute);
}
} catch (_) {
return TimeOfDay.now();
}
}