搜尋套件、儲存庫與 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

所屬分類

原始碼儲存庫

使用此套件的專案