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

flutter_date_range_picker 封面
套件詳情v0.3.0

flutter_date_range_picker

支援透過輸入、對話框和日曆選項選擇日期範圍的 Flutter 套件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
5330
喜歡數
66
Pub 分數
160

安裝套件

flutter pub add flutter_date_range_picker

套件介紹

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

一個 Flutter 套件,讓使用者能透過多種介面(包含輸入欄位、對話方塊與互動式日曆)選擇日期範圍。它支援所有主要平台——Android、iOS、Web、macOS、Windows 與 Linux,非常適合需要彈性日期範圍選擇的跨平台應用。此套件提供乾淨且可自訂的 UI,內建驗證功能,並支援日期間直覺導航。可輕鬆整合至表單與工作流程中,適用於需要時間區間的場景。

適用情境

  • 表單輸入需要日期範圍
  • 預訂或排程系統
  • 按日期區間篩選資料
  • 活動規劃應用程式
  • 帶日期範圍選擇的報告工具
  • 基於日曆的儀表板

主要特色

  • 多選模式(輸入、對話框、日曆)
  • 跨平台相容性
  • 可自訂的 UI 與樣式
  • 內建日期驗證
  • 支援單一與多個日期範圍
  • 與現有 Flutter 表單的輕鬆整合

適合對象

  • 開發跨平台應用的開發者
  • 需要日期範圍篩選的應用程式
  • 包含日期輸入的介面密集型表單
  • 排程與預訂平台
  • 需要時間間隔選擇的工具

使用建議

  • 需要仔細處理日期格式化
  • 可能需要額外的本地化設定
  • 自定樣式可能需要深入理解小部件組合
  • 僅限日期選擇(無時間組件)
  • 未針對非常大的日期範圍進行優化

原始 README

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

Date Range Picker 📅

Date Range Picker is a user-friendly and simple package for Flutter that allows users to select a date range. It's designed to evolve over time, and its components are built to be reusable.

Date Range Picker

(Isn't it beautiful?)

Features ✅

  • Simple and user-friendly interface
  • Customizable theme
  • Reusable components
  • Field, form field, and dialog widgets
  • Functions to display a date range picker as a dialog
  • Supports minimum and maximum date limitations
  • Displays two months at once for easy navigation

Installation 🪛

Add the package to your pubspec.yaml file:

dependencies:
  date_range_picker: ^latest_version

Then, run flutter packages get in your terminal.

Usage 📖

To use the Date Range Picker, simply import the package and create a DateRangePickerWidget:

DateRangePickerWidget(
    doubleMonth: doubleMonth,
    maximumDateRangeLength: 10,
    minimumDateRangeLength: 3,
    initialDateRange: selectedDateRange,
    disabledDates: [DateTime(2023, 11, 20)],
    initialDisplayedDate:
    selectedDateRange?.start ?? DateTime(2023, 11, 20),
    onDateRangeChanged: onDateRangeChanged,
);

You can also use the DateRangeField or DateRangeFormField to display a dialog asking the user to select a date range, and to display the selected range. Here is an example:

DateRangeField(
    decoration: InputDecoration(
        label: Text("Date range picker"),
        hintText: 'Please select a date range',
    ),
    onDateRangeSelected: (DateRange? value) {
    // Handle the selected date range here
    },
  selectedDateRange: selectedRange,
);

Lastly, you can use the showDateRangePickerDialog function to display a dialog asking the user to select a date range:

showDateRangePickerDialog(
    context: context, 
    builder: datePickerBuilder
);
...

Widget datePickerBuilder(BuildContext context, dynamic Function(DateRange) onDateRangeChanged) => DateRangePickerWidget(
    doubleMonth: true,
    initialDateRange: selectedDateRange,
    onDateRangeChanged: onDateRangeChanged,
);

Customization 🎨

You can customize the appearance of the Date Range Picker by providing a custom CalendarTheme:

DateRangePickerWidget(
    onDateRangeChanged: (dateRange) {
    // Handle the selected dateRange here
    },
    theme: CalendarTheme(
    selectedColor: Colors.blue,
    dayNameTextStyle: TextStyle(color: Colors.black45, fontSize: 10),
    inRangeColor: Color(0xFFD9EDFA),
    inRangeTextStyle: TextStyle(color: Colors.blue),
    selectedTextStyle: TextStyle(color: Colors.white),
    todayTextStyle: TextStyle(fontWeight: FontWeight.bold),
    defaultTextStyle: TextStyle(color: Colors.black, fontSize: 12),
    radius: 10,
    tileSize: 40,
    disabledTextStyle: TextStyle(color: Colors.grey),
    )
,
);

License 📜

This package is released under the MIT License.

Contributing 🤝

We encourage and welcome contributions from the community to help improve and grow this project. If you would like to contribute, please feel free to fork the repository, make changes, and submit a pull request.

If you have any questions or need guidance, don't hesitate to reach out to the maintainer of this project. We appreciate your interest and support, and we look forward to collaborating with you!

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案