showDurationPicker function

Future<Duration?> showDurationPicker({
  1. required BuildContext context,
  2. required Duration initialTime,
  3. BaseUnit baseUnit = BaseUnit.minute,
  4. double snapToMins = 1.0,
  5. BoxDecoration? decoration,
})

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,
  BoxDecoration? decoration,
}) async {
  return showDialog<Duration>(
    context: context,
    builder: (BuildContext context) => DurationPickerDialog(
      initialTime: initialTime,
      baseUnit: baseUnit,
      snapToMins: snapToMins,
      decoration: decoration,
    ),
  );
}