showDurationPicker function

Future<Duration?> showDurationPicker({
  1. required BuildContext context,
  2. required Duration initialTime,
  3. BaseUnit baseUnit = BaseUnit.minute,
  4. double snapToMins = 1.0,
  5. Duration? minTime,
  6. Duration? maxTime,
  7. bool enableHapticFeedback = true,
})

Shows a dialog containing the duration picker.

The returned Future resolves to the duration 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:

showDurationPicker(
  initialTime: new Duration.now(),
  context: context,
);

Implementation

Future<Duration?> showDurationPicker({
  required BuildContext context,
  required Duration initialTime,
  BaseUnit baseUnit = BaseUnit.minute,
  double snapToMins = 1.0,
  Duration? minTime,
  Duration? maxTime,
  bool enableHapticFeedback = true,
}) async {
  return await showDialog<Duration>(
    context: context,
    builder: (BuildContext context) => DurationPickerDialog(
      initialTime: initialTime,
      minTime: minTime,
      maxTime: maxTime,
      baseUnit: baseUnit,
      snapToMins: snapToMins,
      enableHapticFeedback: enableHapticFeedback,
    ),
  );
}