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