gpt4 book ai didi

flutter - CupertinoDatePicker 禁用当前时间之前的小时和分钟

转载 作者:行者123 更新时间:2023-12-04 04:20:34 25 4
gpt4 key购买 nike

** Example Image, we can't scroll to the time before current time & day

In the minimumDate param, we can't control the minimum time.

`  CupertinoDatePickerTest(                             
onDateTimeChanged: (DateTime newdate) {
print(newdate);
},
use24hFormat: false,
maximumDate: DateTime.now().add(Duration(days: 2)),
minimumDate:DateTime.now().subtract(Duration(days: 1)),
minuteInterval: 1,
mode: CupertinoDatePickerMode.dateAndTime,
)`

最佳答案

您可以在 CupertinoDatePicker 小部件中使用 minimumDate 属性,以下代码将禁用当前时间之前的小时和分钟:

CupertinoDatePicker(
minimumDate: DateTime.now(), //Min Date time is current time
}

如果您想限制最大日期,您也可以使用 maximumDate 属性:

maximumDate: DateTime.now().add(Duration(days: 2)), //Max Date is after tomorrow

关于flutter - CupertinoDatePicker 禁用当前时间之前的小时和分钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59478670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com