I have a datepicker in flutter. Now I need to disable all the previous days from present date in calendar in flutter. When I tried to do , it only disable the one previous day. If someone can try this, it will be helpful.
final DateTime picked = await showDatePicker(
    selectableDayPredicate: (DateTime val) =>
    val.day == DateTime.now().day - 1 ? false : true,
    context: context,
    initialDate: DateTime.now(),
    firstDate: new DateTime.now().subtract(new Duration(days: 30)),
    lastDate: DateTime(2101));
I got the solution as this for my question, might be useful for someone. If it helped anybody then accept my answer as correct.
final DateTime picked = await showDatePicker(
  context: context,
  initialDate: DateTime.now(),
  firstDate: DateTime.now().subtract(Duration(days: 1)),
  lastDate: DateTime(2100),
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With