搜索插件、代码仓与 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);
                        }
                      },
                    ),
                ),
            )

所属分类

源码仓库

使用此插件的项目