showDurationPicker function Null safety

Future<Duration?> showDurationPicker(
  1. {required BuildContext context,
  2. required Duration initialDuration,
  3. DurationPickerMode? durationPickerMode,
  4. bool showHead = true,
  5. String? confirmText,
  6. String? cancelText}
)

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 initialDuration equal to the Duration with 0 milliseconds: To show a dialog with DurationPickerMode equal to the Duration Mode like hour, second,etc.: To show a dialog with showHead equal to boolean (Default is true) to show Head as Duration:

Optionally provide your own text for the confirm button [confirmText. If null, the button uses MaterialLocalizations.okButtonLabel.

Optionally provide your own text for the cancel button cancelText. If null, the button uses MaterialLocalizations.cancelButtonLabel.

showDurationPicker(
  initialDuration: initialDuration,
  durationPickerMode: durationPickerMode,
  showHead: showHead,
  confirmText: confirmText,
  cancelText: cancelText,
   );

Implementation

Future<Duration?> showDurationPicker(
    {required BuildContext context,
    required Duration initialDuration,
    DurationPickerMode? durationPickerMode,
    bool showHead = true,
    String? confirmText,
    String? cancelText}) async {
  return await showDialog<Duration>(
    context: context,
    builder: (BuildContext context) => new _DurationPickerDialog(
      initialDuration: initialDuration,
      durationPickerMode: durationPickerMode,
      showHead: showHead,
      confirmText: confirmText,
      cancelText: cancelText,
    ),
  );
}