From 0ac9fc638d4200635571041da69b95a3882d6416 Mon Sep 17 00:00:00 2001 From: Wyatt Arent Date: Sat, 22 Oct 2016 23:03:47 -0700 Subject: [PATCH] Cancel button behavior for showdatepicker/showtimepicker (#6486) Cancel button behavior for showdatepicker/showtimepicker Fixes #6483 --- packages/flutter/lib/src/material/date_picker.dart | 6 ++---- packages/flutter/lib/src/material/time_picker.dart | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 527ebd2a15..fa6f372e4d 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -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 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 showDatePicker({ lastDate: lastDate ) ); - return picked ?? initialDate; } diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index 75b20fbb1d..09ff57e7ad 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -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 showTimePicker({ return await showDialog( context: context, child: new _TimePickerDialog(initialTime: initialTime) - ) ?? initialTime; + ); }