showTimePicker function

Future<TimeOfDay> showTimePicker ({@required BuildContext context, @required TimeOfDay initialTime })

Shows a dialog containing a material design time picker.

The returned Future resolves to the time selected by the user when the user closes the dialog. If the user cancels the dialog, null is returned.

To show a dialog with initialTime equal to the current time:

  initialTime: new,
  context: context,

The context argument is passed to showDialog, the documentation for which discusses how it is used.

See also:


Future<TimeOfDay> showTimePicker({
  @required BuildContext context,
  @required TimeOfDay initialTime
}) async {
  assert(context != null);
  assert(initialTime != null);

  return await showDialog<TimeOfDay>(
    context: context,
    child: new _TimePickerDialog(initialTime: initialTime),