From 0b243cd48c3829093accd97075cc458e9d870301 Mon Sep 17 00:00:00 2001 From: Gaspard Merten Date: Mon, 7 Mar 2022 10:56:37 +0100 Subject: [PATCH] Fixing initialDate behaviour --- example/lib/main.dart | 3 ++- lib/src/field.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 026912c..5b54c39 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -74,7 +74,8 @@ class _MyHomePageState extends State { labelText: 'My Super Date Time Field', ), firstDate: DateTime.now().add(const Duration(days: 10)), - initialDate: DateTime.now().add(const Duration(days: 10)), + lastDate: DateTime.now().add(const Duration(days: 40)), + initialDate: DateTime.now().add(const Duration(days: 20)), autovalidateMode: AutovalidateMode.always, validator: (DateTime? e) => (e?.day ?? 0) == 1 ? 'Please not the first day' : null, diff --git a/lib/src/field.dart b/lib/src/field.dart index 13c4c46..0ae0a5c 100644 --- a/lib/src/field.dart +++ b/lib/src/field.dart @@ -121,7 +121,7 @@ class DateTimeField extends StatelessWidget { if (firstDate.isAfter(now) || lastDate.isBefore(now)) { initialDateTime = initialDate ?? lastDate; } else { - initialDateTime = now; + initialDateTime = initialDate ?? now; } }