TimePicker 时间选择
代码演示
基本用法
dart
TimePicker(
value: model.value,
onChange: (value) => model.value = value,
),
选项类型
dart
TimePicker(
columnsType: const {
TimePickerColumn.hour,
TimePickerColumn.minute
},
value: model.value,
onChange: (value) => model.value = value,
),
时间范围
dart
TimePicker(
columnsType: const {
TimePickerColumn.hour,
TimePickerColumn.minute
},
minHour: 10,
maxHour: 20,
minMinute: 30,
maxMinute: 40,
value: model.value,
onChange: (value) => model.value = value,
),
格式化选项
dart
TimePicker(
columnsType: const {
TimePickerColumn.hour,
TimePickerColumn.minute
},
formatter: {
TimePickerColumn.hour: (option) =>
option..name = "${option.value}时",
TimePickerColumn.minute: (option) =>
option..name = "${option.value}分",
TimePickerColumn.second: (option) =>
option..name = "${option.value}秒",
},
value: model.value,
onChange: (value) => model.value = value,
),
过滤选项
dart
TimePicker(
columnsType: const {
TimePickerColumn.hour,
TimePickerColumn.minute
},
filter: {
TimePickerColumn.minute: (options) =>
List.of(options.where((m) => m.value % 10 == 0)),
},
value: model.value,
onChange: (value) => model.value = value,
),
API
Props | 类型 | 描述 |
---|---|---|
columnsType | Set<hour | minute | second> | 时间列 |
value | List<int> | 当前值 |
onChange | List<int> | 值变化触发 |
minHour | int | 最小小时 |
maxHour | int | 最大小时 |
minMinute | int | 最小分钟 |
maxMinute | int | 最大分钟 |
minSecond | int | 最小秒 |
maxSecond | int | 最大秒 |
minHour | Map<hour | minute | second, NamedValue Function(NamedValue option) | 选项格式化 |
filter | Map<hour | minute | second, List<NamedValue> Function(List<NamedValue>) | 过滤选项 |
title | Widget | String | 面板标题 |
confirmText | String | 确认文本 |
cancelText | String | 取消文本 |
onConfirm | Function(List<int>) | 确认触发 |
onCancel | Function(List<int>) | 取消触发 |