Commit 0ac9fc63 authored by Wyatt Arent's avatar Wyatt Arent Committed by Adam Barth

Cancel button behavior for showdatepicker/showtimepicker (#6486)

Cancel button behavior for showdatepicker/showtimepicker

Fixes #6483 
parent c176346e
...@@ -670,8 +670,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { ...@@ -670,8 +670,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
/// Shows a dialog containing a material design date picker. /// Shows a dialog containing a material design date picker.
/// ///
/// The returned [Future] resolves to the date selected by the user when the /// 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] /// user closes the dialog. If the user cancels the dialog, null is returned.
/// resolves to the initialDate.
/// ///
/// See also: /// See also:
/// ///
...@@ -683,7 +682,7 @@ Future<DateTime> showDatePicker({ ...@@ -683,7 +682,7 @@ Future<DateTime> showDatePicker({
DateTime firstDate, DateTime firstDate,
DateTime lastDate DateTime lastDate
}) async { }) async {
DateTime picked = await showDialog( return await showDialog(
context: context, context: context,
child: new _DatePickerDialog( child: new _DatePickerDialog(
initialDate: initialDate, initialDate: initialDate,
...@@ -691,5 +690,4 @@ Future<DateTime> showDatePicker({ ...@@ -691,5 +690,4 @@ Future<DateTime> showDatePicker({
lastDate: lastDate lastDate: lastDate
) )
); );
return picked ?? initialDate;
} }
...@@ -712,8 +712,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { ...@@ -712,8 +712,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
/// Shows a dialog containing a material design time picker. /// Shows a dialog containing a material design time picker.
/// ///
/// The returned Future resolves to the time selected by the user when the user /// 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 /// closes the dialog. If the user cancels the dialog, null is returned.
/// the [initialTime].
/// ///
/// To show a dialog with [initialTime] equal to the current time: /// To show a dialog with [initialTime] equal to the current time:
/// ```dart /// ```dart
...@@ -735,5 +734,5 @@ Future<TimeOfDay> showTimePicker({ ...@@ -735,5 +734,5 @@ Future<TimeOfDay> showTimePicker({
return await showDialog( return await showDialog(
context: context, context: context,
child: new _TimePickerDialog(initialTime: initialTime) child: new _TimePickerDialog(initialTime: initialTime)
) ?? initialTime; );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment