Flutter Datetime Picker
受 flutter-cupertino-date-picker 启发的 Flutter 日期时间选择器。
您可以在英语、荷兰语、中文和俄语中选择日期/时间/日期&时间
您还可以自定义自己的选择器内容。
| 日期选择器 | 时间选择器 | 日期时间选择器 |
|---|---|---|
![]() |
![]() |
![]() |
国际化
| 日期时间选择器(中文) | 日期时间选择器(美式) | 日期时间选择器(荷兰语) | 日期时间选择器(俄语) |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
用法
FlatButton(
onPressed: () {
DatePicker.showDatePicker(context,
showTitleActions: true,
minTime: DateTime(2018, 3, 5),
maxTime: DateTime(2019, 6, 7), onChanged: (date) {
print('change $date');
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime.now(), locale: LocaleType.zh);
},
child: Text(
'show date time picker (Chinese)',
style: TextStyle(color: Colors.blue),
));
自定义
如果您想自定义自己的日期时间选择器样式,有一个名为CommonPickerModel的类,每种类型的日期时间选择器都继承自这个类,您可以参考其他选择器模型(例如DatePickerModel),并编写自己的自定义模型,然后将此模型传递给showPicker方法,这样您自己的日期时间选择器就会出现,很简单,并且可以完美满足您的需求。






