搜索插件、代码仓与 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 和样式
  • 内置日期验证
  • 支持单个和多个日期范围
  • 与现有 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 项

源码仓库

使用此插件的项目