toJson method

  1. @override
String? toJson(
  1. TimeOfDay? object
)

Implementation

@override
String? toJson(TimeOfDay? object) {
  if (object == null) {
    return null;
  }

  String _addLeadingZeroIfNeeded(int value) {
    if (value < 10)
      return '0$value';
    return value.toString();
  }

  final String hourLabel = _addLeadingZeroIfNeeded(object.hour);
  final String minuteLabel = _addLeadingZeroIfNeeded(object.minute);

  return '$hourLabel:$minuteLabel';
}