fromJson method

  1. @override
TimeOfDay? fromJson(
  1. String? json
)

Implementation

@override
TimeOfDay? fromJson(String? json) {
  if (json == null || !json.contains(':')) {
    return null;
  }
  final vars = json.split(':');
  int? hour = int.tryParse(vars[0]);
  int? minute = int.tryParse(vars[1]);
  if (hour == null || minute == null) {
    return null;
  }
  return TimeOfDay(hour: hour, minute: minute);
}