搜索插件、代码仓与 APP 分类

插件详情v4.0.0+13

interval_time_picker

一种可选择时间间隔的默认 Flutter 时钟选择器变体。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
10
喜欢数
27
Pub 分数
160

安装插件

flutter pub add interval_time_picker

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,扩展了默认的时间选择器,允许选择时间间隔而非单个时间。它使用户能够从预定义的时间段中进行选择,非常适合需要固定时间间隔的调度应用程序。该包支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,确保在各种设备上行为一致。使用 Dart 编写,可无缝集成到 Flutter 项目中,并提供简洁、可自定义的基于时间间隔的选择界面。

适合场景

  • 安排固定时间槽的预约
  • 需要基于时间段选择时间的预订系统
  • 带有预设间隔的时间跟踪工具
  • 事件规划使用固定时长的时段
  • 在线课程或会议时间选择

主要特点

  • 支持自定义间隔时长
  • 直观的区间选择用户界面
  • 跨平台兼容性
  • 轻松集成到Flutter应用
  • 可配置的开始和结束时间
  • 适用于所有屏幕尺寸的响应式设计

适合对象

  • 开发预约预订应用程序的开发者
  • 创建时间跟踪软件的团队
  • 提供定时课程的教育平台
  • 任何需要结构化时间输入的应用程序

使用建议

  • 需要仔细配置间隔以避免用户混淆
  • 可能需要对边缘情况额外验证
  • 仅限时间选择(无日期)
  • 不适用于动态或不规则的时间范围
  • 在时间槽可预测且均匀时效果最佳

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Interval Time Picker

pub version likes pub points

This package modifies the default Flutter Time Picker widget by adding interval options when picking minutes. This means you can restrict the user from picking only certain intervals of minutes and you can choose to which interval of minutes the Time Picker will snap to in dial mode.

Version notes
  • Flutter 2.0.0 until 3.7.12 should use version 1.1.0+4.
  • Flutter 3.1.0 until 3.19.6 should use version 2.0.0+5.
  • Flutter 3.22.x should use version 3.0.2+8.
  • Flutter 3.24.0 until 3.32.8 should use version 3.0.4+10.
  • Flutter 3.35.0 and higher should use version 4.0.0+13.
Usage

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  interval_time_picker: ^4.0.0+13

On top of your code add the following import:

import 'package:interval_time_picker/interval_time_picker.dart';

In your code you can then call:

showIntervalTimePicker(
    context: context,
    initialTime: TimeOfDay.fromDateTime(DateTime.now()),
    interval: 5,
    visibleStep: VisibleStep.fifths,
);
Explanation

This package adds two parameters:

  • interval
  • visibleStep

In most cases it is recommended to set the Interval and VisibleStep as the same: i.e. respectively 5 and VisibleStep.fifths or 12 and VisibleStep.twelfths.

Interval

The interval parameter is the steps the Interval Time Picker uses when validating the chosen time (minutes) as well as the steps it rounds off to.
The default and minimum value is 1 minute. The maximum is 60 minutes.

It is actually possible to also use an interval that is not a factor of 60.
So i.e., if you want to use 7 you can use that as well. In that case the highest pickable minute is 56 and going higher will pick 0.

This package also fixes the issue that individual minutes are only selectable by dragging the ring:
Flutter issue #62424

VisibleStep

The visibleStep parameter is the minute labels that are visible on the ring. Choose the steps by using the VisibleStep enum.
The options are a factor of 60 with 5 being the lowest and 60 (shown as 00) being the highest. The default value is VisibleStep.fifths.

Disclaimers
  • If the initial minute is not a multiplication of the interval it will still pick that minute. So handle this yourself when calling showIntervalTimePicker.
Contributions
  • https://github.com/markj
  • https://github.com/MarkCLinovy
  • https://github.com/nilsreichardt
  • https://github.com/hromov
  • https://github.com/harshgmx47
  • https://github.com/pamafe1976

所属分类

源码仓库

使用此插件的项目