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

套件詳情v1.0.7

date_range_picker

日期範圍選擇器在行動裝置上使用對話方塊來選擇日期範圍。

近 30 天下載
796
喜歡數
119
Pub 分數
25

安裝套件

flutter pub add date_range_picker

套件介紹

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

date_range_picker 套件提供了一個適用於行動裝置的日期範圍選擇器元件,以對話框形式顯示,用於選擇起始與結束日期。此套件專為針對行動平台設計的 Flutter 應用程式而打造,提供直覺的介面讓使用者選取日期範圍。該套件與 Flutter 的材質設計原則無縫整合,並支援自訂選擇器的外觀與行為。非常適合用於預訂系統、排程應用程式,或任何需要日期範圍輸入的應用程式。

適用情境

  • 預訂系統
  • 排程應用程式
  • 按日期範圍篩選資料
  • 旅行規劃工具
  • 事件註冊表單

主要特色

  • 基於對話框的日期選擇
  • 開始和結束日期範圍選擇
  • 行動裝置優化的使用者介面
  • 可自訂外觀
  • 與 Flutter 的輕鬆整合

適合對象

  • 行動應用程式開發人員
  • 日期範圍輸入需要
  • Material Design 應用
  • 預訂與日曆功能
  • 使用者友善的日期選擇

使用建議

  • 僅限行動平台
  • 不支援伺服器端渲染
  • 需要手動處理日期邏輯
  • 可能需要額外的樣式以支援深色模式
  • 依賴外部 GitHub 倉庫

原始 README

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

Awesome Flutter pub version

[Deprecated] Date Range Picker

Currently Flutter has supported date range picker, so I think my mission is done. Thanks for using my lib. Link: https://api.flutter.dev/flutter/material/showDateRangePicker.html

Demo

Getting Started

Installation

Add to pubspec.yaml in dependencies

  date_range_picker: ^1.0.5
Usage
import 'package:date_range_picker/date_range_picker.dart' as DateRagePicker;
...
new MaterialButton(
    color: Colors.deepOrangeAccent,
    onPressed: () async {
      final List<DateTime> picked = await DateRagePicker.showDatePicker(
          context: context,
          initialFirstDate: new DateTime.now(),
          initialLastDate: (new DateTime.now()).add(new Duration(days: 7)),
          firstDate: new DateTime(2015),
          lastDate: new DateTime(DateTime.now().year + 2)
      );
      if (picked != null && picked.length == 2) {
          print(picked);
      }
    },
    child: new Text("Pick date range")
)
Theme Customization

To change the colors to your preferred ones, you can wrap it in a Theme and a builder.

Theme(
    data: Theme.of(context).copyWith(
        accentColor: Colors.green,
        primaryColor: Colors.black,
        buttonTheme: ButtonThemeData(
        highlightColor: Colors.green,
        buttonColor: Colors.green,
        colorScheme: Theme.of(context).colorScheme.copyWith(
            secondary: Colors.red,
            background: Colors.white,
            primary: Colors.green,
            primaryVariant: Colors.green,
            brightness: Brightness.dark,
            onBackground: Colors.green),
            textTheme: ButtonTextTheme.accent)),
            child: Builder(
                builder: (context) => RaisedButton(
                    color: Color.fromRGBO(212, 20, 15, 1.0),
                    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
                    child: Padding(
                        padding: const EdgeInsets.only(top: 10.0, bottom: 10.0, left: 30.0, right: 30.0),
                        child: Text(
                          "Date Picker",
                          style: TextStyle(
                            color: primaryColor,
                            fontSize: 28,
                            fontWeight: FontWeight.w300,
                          ),
                        ),
                      ),
                      onPressed: () async {
                        final List<DateTime> picked = await DateRangePicker.showDatePicker(
                            context: context,
                            initialFirstDate: new DateTime.now(),
                            initialLastDate: (new DateTime.now()).add(new Duration(days: 7)),
                            firstDate: new DateTime(2015),
                            lastDate: new DateTime(DateTime.now().year + 2));
                        if (picked != null && picked.length == 2) {
                          print(picked);
                        }
                      },
                    ),
                ),
            )

所屬分類

原始碼儲存庫

使用此套件的專案