How to disable previous days in calendar in flutter?

孤人 提交于 2020-03-21 02:16:30

问题


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

回答1:


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),
);


来源:https://stackoverflow.com/questions/59471397/how-to-disable-previous-days-in-calendar-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!