搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.3

flutter_time_range

一個完全可自訂的 Flutter 小部件,允許使用者選擇時間範圍(從 - 到)

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
45
喜歡數
24
Pub 分數
140

安裝套件

flutter pub add flutter_time_range

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個完全可自訂的 Flutter 小部件,旨在讓使用者選擇一個時間範圍,從起始時間到結束時間。它支援直覺式的時間選擇,並在多個平台提供流暢的使用者介面互動。此小部件非常適合用於排程、預約,或任何需要時間區間輸入的應用程式。設計時著重彈性,允許開發者自訂外觀、行為與驗證規則。相容於 Android、iOS、Web、macOS、Windows 與 Linux,適用於跨平台應用程式。

適用情境

  • 安排預約
  • 預訂系統
  • 活動策劃
  • 時間追蹤工具
  • 自定時間輸入表單

主要特色

  • 可自定義的時間範圍選擇器
  • 支援多個平台
  • 可設定的開始/結束時間限制
  • 流暢的使用者介面互動
  • 可擴充的樣式選項
  • 內建驗證

適合對象

  • 跨平台應用
  • 預約預訂功能
  • 基於時間的資料輸入
  • 需要靈活時間輸入的開發者
  • UI密集型的排程介面

使用建議

  • 需要手動處理時間邏輯
  • 有限的內建時區支援
  • 可能需要對邊緣情況額外驗證
  • 未針對非常大的時間範圍進行優化

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

flutter_time_range Build Status

A fully customizable flutter widget that allowing users to choose time range (from - to)

Showcase

ezgif com-gif-maker

Example

(See example for more detail)

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        navigatorKey: _navigatorKey,
        scaffoldMessengerKey: _messangerKey,
        title: 'Test Time Range Picker',
        home: Scaffold(
          appBar: AppBar(
            title: Text("Time Range Picker"),
          ),
          body: TextButton(
            child: Text("Show Dialog"),
            onPressed: () {
              showTimeRangePicker(_navigatorKey.currentState.overlay.context);
            },
          ),
        ));
  }

  // 24 Hour Format
  Future<void> showTimeRangePicker(BuildContext context) {
    return showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text("Choose event time"),
            content: TimeRangePicker(
              initialFromHour: DateTime.now().hour,
              initialFromMinutes: DateTime.now().minute,
              initialToHour: DateTime.now().hour,
              initialToMinutes: DateTime.now().minute,
              backText: "Back",
              nextText: "Next",
              cancelText: "Cancel",
              selectText: "Select",
              editable: true,
              is24Format: true,
              disableTabInteraction: true,
              iconCancel: Icon(Icons.cancel_presentation, size: 12),
              iconNext: Icon(Icons.arrow_forward, size: 12),
              iconBack: Icon(Icons.arrow_back, size: 12),
              iconSelect: Icon(Icons.check, size: 12),
              separatorStyle: TextStyle(color: Colors.grey[900], fontSize: 30),
              onSelect: (from, to) {
                _messangerKey.currentState.showSnackBar(
                    SnackBar(content: Text("From : $from, To : $to")));
                Navigator.pop(context);
              },
              onCancel: () => Navigator.pop(context),
            ),
          );
        });
  }

  // 12 Hour Format and custom style
  Future<void> showTimeRangePicker12Hour(BuildContext context) {
    return showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text("Choose event time"),
            content: TimeRangePicker(
              initialFromHour: DateTime.now().hour,
              initialFromMinutes: DateTime.now().minute,
              initialToHour: DateTime.now().hour,
              initialToMinutes: DateTime.now().minute,
              backText: "Back",
              nextText: "Next",
              cancelText: "Cancel",
              selectText: "Select",
              editable: true,
              is24Format: false,
              disableTabInteraction: true,
              iconCancel: Icon(Icons.cancel_presentation, size: 12),
              iconNext: Icon(Icons.arrow_forward, size: 12),
              iconBack: Icon(Icons.arrow_back, size: 12),
              iconSelect: Icon(Icons.check, size: 12),
              inactiveBgColor: Colors.grey[800],
              timeContainerStyle: BoxDecoration(
                  color: Colors.grey[800],
                  borderRadius: BorderRadius.circular(7)),
              separatorStyle: TextStyle(color: Colors.grey[900], fontSize: 30),
              onSelect: (from, to) {
                _messangerKey.currentState.showSnackBar(
                    SnackBar(content: Text("From : $from, To : $to")));
                Navigator.pop(context);
              },
              onCancel: () => Navigator.pop(context),
            ),
          );
        });
  }

TODOS

need feedback

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。