showMaterialTimePicker function
Future<TimeOfDay?>
showMaterialTimePicker({
- required BuildContext context,
- String? title,
- required TimeOfDay selectedTime,
- String? confirmText,
- String? cancelText,
- ValueChanged<
TimeOfDay> ? onChanged, - VoidCallback? onConfirmed,
- VoidCallback? onCancelled,
Allows selection of a time
Implementation
Future<TimeOfDay?> showMaterialTimePicker({
required BuildContext context,
/// The title for the dialog box
String? title,
/// The initially selected time
required TimeOfDay selectedTime,
/// Text to display in the confirm button
String? confirmText,
/// Text to display in the cancel button
String? cancelText,
/// Function that gets called when the value is changed
ValueChanged<TimeOfDay>? onChanged,
/// Function that gets called when the confirm button is pressed
VoidCallback? onConfirmed,
/// Function that gets called when the cancel button is pressed
VoidCallback? onCancelled,
}) {
return showTimePicker(
context: context,
initialTime: selectedTime,
cancelText: cancelText,
confirmText: confirmText,
helpText: title,
).then((selection) {
if (selection != null) {
onChanged?.call(selection);
onConfirmed?.call();
} else {
onCancelled?.call();
}
return selection;
});
}