Flutter date range pickers use a dialog window to select a range of date on mobile.

Overview
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);
                        }
                      },
                    ),
                ),
            )
Comments
  • [FEATURE] Maximum selectable span

    [FEATURE] Maximum selectable span

    In my case I need to give to user the possibility to select max 7 days span. At the moment the span selection is free. It will be a very good feature to add to this package, something like:

    DateRagePicker.showDatePicker(
              context: context,
              …
              maxSelectableSpan: 7
    )
    
    opened by enricobenedos 1
  • List<DateTime> returns a null object if only one date is selected

    List returns a null object if only one date is selected

    I've run into an issue where if the DateRangePicker returns with only one date selected, the List<DateTime> returned will be of length == 2 but only the first item will be a valid DateTime object while the second item is null, which is very misleading if I'm using the length of the List<DateTime> to verify that the user has selected a date range rather than a single date.

    opened by juanchazo 1
  • Fixed two run time exceptions

    Fixed two run time exceptions

    Exception 1: occurred when you select a start date, then end date, then re-select the same start date. This was causing the code to reference an end date that was already cleared. I removed the condition widget.selectedFirstDate != oldWidget.selectedFirstDate which fixed the exception. I have not been able to find any error caused by this removal.

    Exception 2: occurred when you select to change the year with only a start date selected. I changed the conditional that was checking if selectedLastDate == null and then using selectedLastDate, to checking if it was != null. Fixed the error I saw and have not been able to produce any new issues with this change.

    opened by calebisstupid 1
  • type 'List<dynamic>' is not a subtype of type 'List<DateTime>' of 'result'

    type 'List' is not a subtype of type 'List' of 'result'

    Function showDatePicker crash with this error when you pick a range of Dates and tap on "OK" button.

    type 'List' is not a subtype of type 'List' of 'result'.

    flutter: When the exception was thrown, this was the stack:
    flutter: #0      _ModalRoute&TransitionRoute&LocalHistoryRoute.didPop (package:flutter/src/widgets/routes.dart)
    flutter: #1      NavigatorState.pop (package:flutter/src/widgets/navigator.dart:1824:15)
    flutter: #2      Navigator.pop (package:flutter/src/widgets/navigator.dart:1183:34)
    flutter: #3      _DatePickerDialogState._handleOk (package:date_range_picker/date_range_picker.dart:1114:15)
    flutter: #4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
    flutter: #5      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
    flutter: #6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
    flutter: #7      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
    flutter: #8      TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
    flutter: #9      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
    flutter: #10     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
    flutter: #11     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
    flutter: #12     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
    flutter: #13     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
    flutter: #14     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
    flutter: #15     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
    flutter: #16     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
    flutter: #17     _invoke1 (dart:ui/hooks.dart:168:13)
    flutter: #18     _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
    
    opened by dyalgrupo 0
  • Method not found: 'ButtonTheme.bar'

    Method not found: 'ButtonTheme.bar'

    When I try to run my app in chrome, I keep getting this error:

    ../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/date_range_picker-1.0.6/lib/date_range_picker.dart:1152:44: Error: Method not found: 'ButtonTheme.bar'. final Widget actions = new ButtonTheme.bar(

    I just updated flutter to the last version of and as posted in this post in StackOverflow, ButtonTheme.bar is deprecated. This results in not being able to run the app in web. I don't use "directly" ButtonTheme, but the package flutter_form_builder does. Someone already posted the issue in flutter_form_builder.

    Maybe a solution would be to modify date_range_picker yourself to replace the ButtonTheme with ButtonBarTheme...

    opened by ZikBurns 7
  • Calendar crash while selecting last index of year.

    Calendar crash while selecting last index of year.

    whenever i am selecting last index of list in year list : for instance i selected 2022 from list of calendar then crash the calendar and show error below

    ═══════ Exception caught by widgets library ═══════════════════════════════════════════════════════ 'package:flutter_calendar/calendar_lib.dart': Failed assertion: line 608 pos 16: '!selectedFirstDate.isBefore(firstDate) && (selectedLastDate == null || !selectedLastDate.isAfter(lastDate))': is not true.

    opened by waqaryounusjatt788 0
Owner
null
Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size.

desktop_window Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size. Usage import 'package:desktop_window/desktop_window.dart

ChunKoo Park 72 Dec 2, 2022
Flutter library for window blur & transparency effects for on Windows & Linux. 💙

flutter_acrylic Window blur & transparency effects for Flutter on Windows & Linux Installation Mention in your pubspec.yaml. dependencies: ... flu

Hitesh Kumar Saini 437 Dec 31, 2022
This plugin allows Flutter desktop apps to resizing and repositioning the window.

window_manager This plugin allows Flutter desktop apps to resizing and repositioning the window. window_manager Platform Support Quick Start Installat

LeanFlutter 351 Jan 7, 2023
A package which provides most of the window decorations from linux themes.

Window Decorations A package which provides most of the window decorations from linux themes. Features Easier to use and implement Native looking wind

Prateek SU 20 Dec 21, 2022
Windows95 UI components for Flutter apps. Bring back the nostalgic look and feel of old operating systems with this set of UI components ready to use.

Flutter95 Windows95 UI components for Flutter apps. UNDER CONSTRUCTION Screenshots Components Scaffold95 Scaffold as a Windows95 styled window. Provid

Miguel Beltran 141 Dec 26, 2022
A Javascript engine to use with flutter. It uses quickjs on Android and JavascriptCore on IOS

Flutter JS plugin A Javascript engine to use with flutter. Now it is using QuickJS on Android through Dart ffi and JavascriptCore on IOS also through

Ábner Oliveira 334 Jan 3, 2023
JavaScriptCore for Flutter use dart:ffi.

flutter_jscore JavaScriptCore for Flutter. The plugin provides the ability to evaluate JavaScript programs from within dart. Demo Screen recording Apk

KnoYo 131 Jan 3, 2023
A project that makes use of a Typescript back end and a Flutter web front end to consume the Jira API in order to visualize and interact with issues.

A project that makes use of a Typescript back end and a Flutter web front end to consume the Jira API in order to visualize and interact with issues.

Lucas Coelho 1 Mar 20, 2022
A simple-to-use flutter update package for Windows, MacOS, and Linux.

Updat - The simple-to-use, flutter-based desktop update package Updat is a simple-to-use reliable flutter-native updater that handles your application

Eduardo M. 14 Dec 21, 2022
Use Dart to call Shell, complete the work of compiling Golang CGO code into a so, dll, a, WASM, and etc.

Use Dart to call Shell, complete the work of compiling Golang CGO code into a so, dll, a, WASM, and etc. And place it in the corresponding source file directory of each Flutter platform.

Dorain Gray 30 Dec 30, 2022
File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.

A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

Miguel Ruivo 987 Jan 6, 2023
A platform adaptive Flutter app for desktop, mobile and web.

Flutter Folio A demo app showcasing how Flutter can deliver a great multi-platform experience, targeting iOS, Android, MacOS, Windows, Linux, and web.

gskinner team 3.5k Jan 2, 2023
Sharik is an open-source, cross-platform solution for sharing files via Wi-Fi or Mobile Hotspot

Share files across devices with Sharik! It works with Wi-Fi connection or Tethering (Wi-Fi Hotspot). No internet connection needed. Contributing Feel

Mark Motliuk 842 Dec 30, 2022
Android-Toolbox is a desktop app which enables the user to access android device features which are not accessible directly from the mobile device

Android-Toolbox is a desktop app which enables the user to access android device features which are not accessible directly from the mobile device. One of Android-Toolbox's special feature is to transfer files at the highest speed using ADB push and pull bypassing a lot of Android API overheads.

Sashank Visweshwaran 30 Dec 26, 2022
Flutter Installer is an installer for Flutter built with Flutter 💙😎✌

Flutter Installer Flutter Installer is an installer for Flutter built with Flutter ?? ?? ✌ Flutter and the related logo are trademarks of Google LLC.

Yazeed AlKhalaf 406 Dec 27, 2022
A Flutter package that makes it easy to customize and work with your Flutter desktop app's system tray.

system_tray A Flutter package that that enables support for system tray menu for desktop flutter apps. on Windows, macOS and Linux. Features: - Modify

AnTler 140 Dec 30, 2022
Fluttern is a web app made with Flutter to list Flutter internships/jobs for the community.

Fluttern Fluttern is a web app made with Flutter to list Flutter internships/jobs for the community. It uses Google Sheet as a backend, simplifying th

Aditya Thakur 3 Jan 5, 2022
Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.

go-flutter - A package that brings Flutter to the desktop Purpose Flutter allows you to build beautiful native apps on iOS and Android from a single c

null 5.5k Jan 6, 2023
A clean front-end plugin to Volumio, the Linux distribution for music playback. Volumio Touch Display Lite is written in Flutter and runs on flutter-pi.

EN | 中文 Touch Display Lite plugin for Volumio 3 Feng Zhou, 2021-12 Touch Display Lite is a clean and fast user interface for Volumio 3, the Linux dist

Feng Zhou 5 Jul 26, 2022