如何在日历中停用前几天? [英] How to disable previous days in calendar in flutter?

查看:70
本文介绍了如何在日历中停用前几天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日期选择器在颤抖。现在,我需要从日历中的当前日期起禁用所有前几天。当我尝试这样做时,它只会禁用前一天。
如果有人可以尝试这样做,将很有帮助。

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

这篇关于如何在日历中停用前几天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆