You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Show Date Picker has an assertion that First Date must be less than Initial Date.
From ShowPicker
assert(!initialDate.isBefore(firstDate), 'initialDate must be on or after firstDate');
assert(!initialDate.isAfter(lastDate), 'initialDate must be on or before lastDate');
assert(!firstDate.isAfter(lastDate), 'lastDate must be on or after firstDate');
If with Form Builder you set the initial date and first date to the exact same time using DateTime.now() the assertion fails and the date will not "popup"
This is a work-around where I set the date one second less.
You might want to consider something like the following (THIS IS NOT TESTED) just straight from my head.
Future<DateTime> _showDatePicker(
BuildContext context, DateTime currentValue) {
DateTime _initDate = currentValue ?? widget.initialDate ?? DateTime.now();
DateTime _firstDate = widget.firstDate ?? DateTime(1900);
if (! _initDate.isAfter(_firstDate) )
_initDate = _initDate.subtract(Duration(seconds: 1));
if (widget.datePicker != null) {
return widget.datePicker(context);
} else {
return showDatePicker(
context: context,
selectableDayPredicate: widget.selectableDayPredicate,
initialDatePickerMode:
widget.initialDatePickerMode ?? DatePickerMode.day,
// ignore: deprecated_member_use_from_same_package
initialDate: _initDate,
firstDate: _firstDate
lastDate: widget.lastDate ?? DateTime(2100));
}
}
For some reason I could not update and step through it, to test it.
Some default setting probably on VSCode that I don't have time to research.
Jamie
The text was updated successfully, but these errors were encountered:
Ok so after I stopped an "recompiled" I could step through the code I think this works, it does work for me. You might want to run an assertion until people fix it, but at least it doesn't inadvertently act up.
I also was able to figure out why it was breaking randomly if you firstdate, before initial value in the list there are enough Microseconds that it works fine.
Here is my think working workaround... You might document this as if you give an initDate <= firstDate it sets it to initDate - 10 seconds
Show Date Picker has an assertion that First Date must be less than Initial Date.
From ShowPicker
If with Form Builder you set the initial date and first date to the exact same time using DateTime.now() the assertion fails and the date will not "popup"
This is a work-around where I set the date one second less.
You might want to consider something like the following (THIS IS NOT TESTED) just straight from my head.
The text was updated successfully, but these errors were encountered: