Fixing initialDate behaviour

This commit is contained in:
Gaspard Merten 2022-03-07 10:56:37 +01:00
parent 63da6010cb
commit 0b243cd48c
2 changed files with 3 additions and 2 deletions

View file

@ -74,7 +74,8 @@ class _MyHomePageState extends State<MyHomePage> {
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,

View file

@ -121,7 +121,7 @@ class DateTimeField extends StatelessWidget {
if (firstDate.isAfter(now) || lastDate.isBefore(now)) {
initialDateTime = initialDate ?? lastDate;
} else {
initialDateTime = now;
initialDateTime = initialDate ?? now;
}
}