showMaterialTimePicker function

void showMaterialTimePicker({
  1. required BuildContext context,
  2. String? title,
  3. required TimeOfDay selectedTime,
  4. String? confirmText,
  5. String? cancelText,
  6. ValueChanged<TimeOfDay>? onChanged,
  7. VoidCallback? onConfirmed,
  8. VoidCallback? onCancelled,
})

Allows selection of a time

Implementation

void showMaterialTimePicker({
  required BuildContext context,
  String? title,
  required TimeOfDay selectedTime,
  String? confirmText,
  String? cancelText,
  ValueChanged<TimeOfDay>? onChanged,
  VoidCallback? onConfirmed,
  VoidCallback? onCancelled,
}) {
  showTimePicker(
    context: context,
    initialTime: selectedTime,
    cancelText: cancelText,
    confirmText: confirmText,
  ).then((selection) {
    if (onChanged != null && selection != null) onChanged(selection);
    if (onCancelled != null && selection == null) onCancelled();
    if (onConfirmed != null && selection != null) onConfirmed();
  });
}