stringToTime static method
convert time (String to TimeOfDay)
Implementation
static TimeOfDay stringToTime({required String? time}) {
if (_isNullOrEmpty(time)) {
return TimeOfDay.now();
} else {
int hour = TimeOfDay.now().hour;
int minute = TimeOfDay.now().minute;
if (time!.toUpperCase().contains(_am) ||
time.toUpperCase().contains(_pm)) {
if (time.toUpperCase().contains(_pm)) {
hour = (int.parse((time.split(' ')[0]).split(':')[0])) + 12;
} else {
hour = (int.parse((time.split(' ')[0]).split(':')[0]));
}
minute = int.parse((time.split(' ')[0]).split(':')[1]);
} else {
hour = int.parse((time.split(' ')[0]).split(':')[0]);
minute = int.parse((time.split(' ')[0]).split(':')[1]);
}
return TimeOfDay(hour: hour, minute: minute);
}
}