convert method
Formats the nullable TimeOfDay into a string representation.
Uses the current date to create a DateTime object, then formats it according to format.
placeHolder is the string returned if the TimeOfDay is null.
format specifies the format string used to format the DateTime object. Defaults to 'hh:mm a'.
Returns the formatted time string or placeHolder if the TimeOfDay is null.
Implementation
String convert({String placeHolder = '', String format = 'hh:mm a'}) {
if (this == null) return placeHolder;
DateTime now = DateTime.now();
final DateTime dateTime = DateTime(
now.year,
now.month,
now.day,
this!.hour,
this!.minute,
);
return dateTime.format(format: format, placeholder: placeHolder);
}