Fixing initialDate behaviour
This commit is contained in:
parent
63da6010cb
commit
0b243cd48c
2 changed files with 3 additions and 2 deletions
|
@ -74,7 +74,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
labelText: 'My Super Date Time Field',
|
labelText: 'My Super Date Time Field',
|
||||||
),
|
),
|
||||||
firstDate: DateTime.now().add(const Duration(days: 10)),
|
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,
|
autovalidateMode: AutovalidateMode.always,
|
||||||
validator: (DateTime? e) =>
|
validator: (DateTime? e) =>
|
||||||
(e?.day ?? 0) == 1 ? 'Please not the first day' : null,
|
(e?.day ?? 0) == 1 ? 'Please not the first day' : null,
|
||||||
|
|
|
@ -121,7 +121,7 @@ class DateTimeField extends StatelessWidget {
|
||||||
if (firstDate.isAfter(now) || lastDate.isBefore(now)) {
|
if (firstDate.isAfter(now) || lastDate.isBefore(now)) {
|
||||||
initialDateTime = initialDate ?? lastDate;
|
initialDateTime = initialDate ?? lastDate;
|
||||||
} else {
|
} else {
|
||||||
initialDateTime = now;
|
initialDateTime = initialDate ?? now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue