flutter - 如何设置默认日期选择器值?
问题描述
我使用日期选择器包来获取日期,这是我的代码
DatePicker(
key: dobKey,
setDate: _setDate,
customShape: StadiumBorder(
side: BorderSide(
color: Color(0xFFF991A0),
)
),
如何设置默认值?喜欢2019-04-15
解决方案
用这个 -
await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now().subtract(Duration(days: 1)),
lastDate: DateTime.now().add(Duration(days: 6570)),
initialDatePickerMode: DatePickerMode.year);
您可以添加 initialDate 以及可能的日期范围。您还可以添加选择器模式。
推荐阅读
- android - ExoPlayer HttpDataSource$InvalidResponseCodeException:响应代码:404
- powerbuilder - PB OLEObject 没有填充 wscript.network 的方法
- javascript - 如何使用 datalist 将对象键传递给函数
- chromecast - 是否有任何解决方案可以在 nay 索引处获取媒体队列项?
- java - Streams deploying stuck and then fails with no errors in the logs
- android-studio - android studio 给我一个错误:(访问被拒绝)
- r - 在 R 中读取 csv 文件后获取额外的符号和数字
- java - 我们可以在spring boot应用程序中随机执行另一个主要功能的单独进程吗?
- php - Google 日历 Yes/Maybe/No 来自 PHP 后端(google-calendar Laravel)
- reporting-services - 报表运行不快?