fix(mobile): allow editing asset dates in the future (#5522)

Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2023-12-07 02:04:03 +00:00 committed by GitHub
parent 8736c77f7a
commit e1739ac4fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;