Cancel button behavior for showdatepicker/showtimepicker (#6486)
Cancel button behavior for showdatepicker/showtimepicker Fixes #6483
This commit is contained in:
@@ -670,8 +670,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
|
||||
/// Shows a dialog containing a material design date picker.
|
||||
///
|
||||
/// The returned [Future] resolves to the date selected by the user when the
|
||||
/// user closes the dialog. If the user cancels the dialog, the [Future]
|
||||
/// resolves to the initialDate.
|
||||
/// user closes the dialog. If the user cancels the dialog, null is returned.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
@@ -683,7 +682,7 @@ Future<DateTime> showDatePicker({
|
||||
DateTime firstDate,
|
||||
DateTime lastDate
|
||||
}) async {
|
||||
DateTime picked = await showDialog(
|
||||
return await showDialog(
|
||||
context: context,
|
||||
child: new _DatePickerDialog(
|
||||
initialDate: initialDate,
|
||||
@@ -691,5 +690,4 @@ Future<DateTime> showDatePicker({
|
||||
lastDate: lastDate
|
||||
)
|
||||
);
|
||||
return picked ?? initialDate;
|
||||
}
|
||||
|
||||
@@ -712,8 +712,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
|
||||
/// 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, the Future resolves to
|
||||
/// the [initialTime].
|
||||
/// closes the dialog. If the user cancels the dialog, null is returned.
|
||||
///
|
||||
/// To show a dialog with [initialTime] equal to the current time:
|
||||
/// ```dart
|
||||
@@ -735,5 +734,5 @@ Future<TimeOfDay> showTimePicker({
|
||||
return await showDialog(
|
||||
context: context,
|
||||
child: new _TimePickerDialog(initialTime: initialTime)
|
||||
) ?? initialTime;
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user