showCustomTimePicker function

Future<TimePickerModel?> showCustomTimePicker({
  1. required BuildContext context,
  2. required TimePickerType type,
  3. TimePickerMode mode = TimePickerMode.single,
  4. DateTime? initialTime,
  5. DateTime? initialStartTime,
  6. DateTime? initialEndTime,
  7. DateTime? minTime,
  8. DateTime? maxTime,
})

构造函数参数 context 上下文环境,用于构建UI type 时间选择器的类型 mode 时间选择器的模式,默认为单选模式 initialTime 初始时间,仅在单选模式下使用 initialStartTime 初始开始时间,仅在范围选择模式下使用 initialEndTime 初始结束时间,仅在范围选择模式下使用 minTime 可选的最小时间限制 maxTime 可选的最大时间限制

Implementation

Future<TimePickerModel?> showCustomTimePicker({
  required BuildContext context,
  required TimePickerType type,
  TimePickerMode mode = TimePickerMode.single,
  DateTime? initialTime,
  DateTime? initialStartTime,
  DateTime? initialEndTime,
  DateTime? minTime,
  DateTime? maxTime,
}) {
  return showModalBottomSheet<TimePickerModel?>(
    context: context,
    backgroundColor: Colors.transparent,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(top: Radius.circular(12.w))
    ),
    builder: (BuildContext context) {
      return CustomTimePicker(
        type: type,
        mode: mode,
        initialTime: initialTime,
        initialStartTime: initialStartTime,
        initialEndTime: initialEndTime,
        minTime: minTime,
        maxTime: maxTime,
      );
    },
  );
}