From e1739ac4fc7301ee3c5f6d9dc8d10e4e828e03af Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Thu, 7 Dec 2023 02:04:03 +0000 Subject: [PATCH] fix(mobile): allow editing asset dates in the future (#5522) Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> --- mobile/lib/shared/ui/date_time_picker.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mobile/lib/shared/ui/date_time_picker.dart b/mobile/lib/shared/ui/date_time_picker.dart index 6c7ea16ce..adc2092f8 100644 --- a/mobile/lib/shared/ui/date_time_picker.dart +++ b/mobile/lib/shared/ui/date_time_picker.dart @@ -86,11 +86,14 @@ class _DateTimePicker extends HookWidget { final timeZones = useMemoized(() => getAllTimeZones(), const []); void pickDate() async { + final now = DateTime.now(); + // Handles cases where the date from the asset is far off in the future + final initialDate = date.value.isAfter(now) ? now : date.value; final newDate = await showDatePicker( context: context, - initialDate: date.value, + initialDate: initialDate, firstDate: DateTime(1800), - lastDate: DateTime.now(), + lastDate: now, ); if (newDate == null) { return;