A flutter date time picker

Overview

Flutter Datetime Picker

(Pub) flutter_datetime_picker

A flutter date time picker inspired by flutter-cupertino-date-picker

you can choose date / time / date&time in multiple languages:

  • Albanian(sq)
  • Arabic(ar)
  • Armenian(hy)
  • Azerbaijan(az)
  • Basque(eu)
  • Bengali(bn)
  • Bulgarian(bg)
  • Catalan(cat)
  • Chinese(zh)
  • Danish(da)
  • Dutch(nl)
  • English(en)
  • French(fr)
  • German(de)
  • Hebrew(he)
  • Indonesian(id)
  • Italian(it)
  • Japanese(jp)
  • Kazakh(kk)
  • Korean(ko)
  • Persian(fa)
  • Polish (pl)
  • Portuguese(pt)
  • Russian(ru)
  • Spanish(es)
  • Swedish(sv)
  • Thai(th)
  • Turkish(tr)
  • Vietnamese(vi)
  • Khmer(kh)

and you can also custom your own picker content

Date picker Time picker Date Time picker

International:

Date Time picker (Chinese) Date Time picker (America) Date Time picker (Dutch) Date Time picker (Russian)

Demo App

main page

Usage

TextButton(
    onPressed: () {
        DatePicker.showDatePicker(context,
                              showTitleActions: true,
                              minTime: DateTime(2018, 3, 5),
                              maxTime: DateTime(2019, 6, 7), onChanged: (date) {
                            print('change $date');
                          }, onConfirm: (date) {
                            print('confirm $date');
                          }, currentTime: DateTime.now(), locale: LocaleType.zh);
    },
    child: Text(
        'show date time picker (Chinese)',
        style: TextStyle(color: Colors.blue),
    ));

Customize

If you want to customize your own style of date time picker, there is a class called CommonPickerModel, every type of date time picker is extended from this class, you can refer to other picker model (eg. DatePickerModel), and write your custom one, then pass this model to showPicker method, so that your own date time picker will appear, it’s easy, and will perfectly meet your demand

How to customize your own picker model:

= 0 && index < 24) { return this.digits(index, 2); } else { return null; } } @override String middleStringAtIndex(int index) { if (index >= 0 && index < 60) { return this.digits(index, 2); } else { return null; } } @override String rightStringAtIndex(int index) { if (index >= 0 && index < 60) { return this.digits(index, 2); } else { return null; } } @override String leftDivider() { return "|"; } @override String rightDivider() { return "|"; } @override List layoutProportions() { return [1, 2, 1]; } @override DateTime finalTime() { return currentTime.isUtc ? DateTime.utc(currentTime.year, currentTime.month, currentTime.day, this.currentLeftIndex(), this.currentMiddleIndex(), this.currentRightIndex()) : DateTime(currentTime.year, currentTime.month, currentTime.day, this.currentLeftIndex(), this.currentMiddleIndex(), this.currentRightIndex()); } }">
class CustomPicker extends CommonPickerModel {
  String digits(int value, int length) {
    return '$value'.padLeft(length, "0");
  }

  CustomPicker({DateTime currentTime, LocaleType locale}) : super(locale: locale) {
    this.currentTime = currentTime ?? DateTime.now();
    this.setLeftIndex(this.currentTime.hour);
    this.setMiddleIndex(this.currentTime.minute);
    this.setRightIndex(this.currentTime.second);
  }

  @override
  String leftStringAtIndex(int index) {
    if (index >= 0 && index < 24) {
      return this.digits(index, 2);
    } else {
      return null;
    }
  }

  @override
  String middleStringAtIndex(int index) {
    if (index >= 0 && index < 60) {
      return this.digits(index, 2);
    } else {
      return null;
    }
  }

  @override
  String rightStringAtIndex(int index) {
    if (index >= 0 && index < 60) {
      return this.digits(index, 2);
    } else {
      return null;
    }
  }

  @override
  String leftDivider() {
    return "|";
  }

  @override
  String rightDivider() {
    return "|";
  }

  @override
  List
    
      layoutProportions() {
    return [1, 2, 1];
  }

  @override
  DateTime finalTime() {
    return currentTime.isUtc
        ? DateTime.utc(currentTime.year, currentTime.month, currentTime.day,
            this.currentLeftIndex(), this.currentMiddleIndex(), this.currentRightIndex())
        : DateTime(currentTime.year, currentTime.month, currentTime.day, this.currentLeftIndex(),
            this.currentMiddleIndex(), this.currentRightIndex());
  }
}

    

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

Comments
  • DiagnosticableMixin not found

    DiagnosticableMixin not found

    ../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.3.8/lib/src/datetime_picker_theme.dart:6:28: Error: Type 'DiagnosticableMixin' not found. class DatePickerTheme with DiagnosticableMixin { ^^^^^^^^^^^^^^^^^^^ ../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.3.8/lib/src/datetime_picker_theme.dart:6:7: Error: The type 'DiagnosticableMixin' can't be mixed in. class DatePickerTheme with DiagnosticableMixin {

    opened by lmanliang 26
  • Compiler message: /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.3.5/lib/src/datetime_picker_theme.dart:4:7: Error: The type 'Diagnosticable' can't be used as supertype. class DatePickerTheme extends Diagnosticable {

    Compiler message: /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.3.5/lib/src/datetime_picker_theme.dart:4:7: Error: The type 'Diagnosticable' can't be used as supertype. class DatePickerTheme extends Diagnosticable {

    At last update of dart Language on my windows PC and Flutter package I can't start my Project anymore, I get every time this error message:

    Compiler message:
    /C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.3.5/lib/src/datetime_picker_theme.dart:4:7: Error: The type 'Diagnosticable' can't be used as supertype.
    class DatePickerTheme extends Diagnosticable {
    
    C:\Users\me\Desktop\bh_app>flutter doctor -v
    [√] Flutter (Channel master, v1.15.22-pre.24, on Microsoft Windows [Version 10.0.18363.657], locale de-DE)
        • Flutter version 1.15.22-pre.24 at C:\src\flutter
        • Framework revision aba0e2dc8f (2 days ago), 2020-03-13 23:21:03 -0400
        • Engine revision e48761e5bb
        • Dart version 2.8.0 (build 2.8.0-dev.14.0 c3a0bb086a)
    
    
    [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
        • Android SDK at C:\Users\me\AppData\Local\Android\sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-28, build-tools 28.0.3
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
        • All Android licenses accepted.
    
    [√] Chrome - develop for the web
        • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
    
    [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.4.6)
        • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
        • Visual Studio Community 2019 version 16.4.29905.134
    
    [√] Android Studio (version 3.6)
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin version 44.0.2
        • Dart plugin version 192.7761
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    
    [√] IntelliJ IDEA Ultimate Edition (version 2019.3)
        • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.3
        • Flutter plugin version 44.0.3
        • Dart plugin version 193.6494.35
    
    [√] VS Code (version 1.43.0)
        • VS Code at C:\Users\me\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.8.1
    
    [√] Connected device (3 available)
        • Windows    • Windows    • windows-x64    • Microsoft Windows [Version 10.0.18363.657]
        • Chrome     • chrome     • web-javascript • Google Chrome 80.0.3987.132
        • Web Server • web-server • web-javascript • Flutter Tools
    
    • No issues found!
    
    name: bh_app
    description: A new Flutter project.
    
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.1.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
      cupertino_icons: ^0.1.2
      provider: ^4.0.1
      google_fonts: ^0.3.2
      outline_material_icons: ^0.1.1
      flutter_datetime_picker: ^1.3.5 <----- here is the package
      intl: ^0.16.1
      http: ^0.12.0+4
      sqflite: ^1.2.0
      path: ^1.6.4
      loading: ^1.0.2
      dio: ^3.0.8
      jose: ^0.1.2
      pdf: ^1.5.0
      printing: ^3.1.0
      js: ^0.6.1+1
      crypted_preferences: ^0.0.2
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    
    flutter:
      uses-material-design: true
    
    opened by Kassan424kh 12
  • Remove parameter `shadowThemeOnly` from ThemeData

    Remove parameter `shadowThemeOnly` from ThemeData

    static ThemeData of BuildContext doesn't contain named parameter shadowThemeOnly:tre. From the latest version of Flutter we gets the error: Error: No named parameter with the name 'shadowThemeOnly'. ThemeData inheritTheme = Theme.of(context, shadowThemeOnly: true);

    opened by sirajulhudalabs 8
  • Error in Flutter1.20

    Error in Flutter1.20

    When I update my Flutter version to 1.20, i can‘t run my project,because error
    ../../../../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.3.8/lib/src/datetime_picker_theme.dart:6:28: Error: Type 'DiagnosticableMixin' not found. class DatePickerTheme with DiagnosticableMixin { ^^^^^^^^^^^^^^^^^^^ ../../../../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.3.8/lib/src/datetime_picker_theme.dart:6:7: Error: The type 'DiagnosticableMixin' can't be mixed in. class DatePickerTheme with DiagnosticableMixin { ^ Any help?

    opened by tongyangsheng 8
  • Modify format date

    Modify format date

    hello, how can I change the date format from "yyyy-mm-dd" to "dd-mmmm-yyyy"? Same thing for the time picker, as change from "hh-mm-ss" to "hh-mm"? Because I didn't find any parameter that allows me to put a pattern for the date.

    opened by AndreaMainella 8
  • Build error Diagnosticable

    Build error Diagnosticable

    Pub/Cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.3.5/lib/src/datetime_picker_theme.dart:4:7: Error: The type 'Diagnosticable' can't be used as supertype.

    $ flutter doctor -v [√] Flutter (Channel master, v1.15.21-pre.2, on Microsoft Windows [Version 10.0.17763.1039], locale de-DE) • Flutter version 1.15.21-pre.2 at D:\flutter • Framework revision 210f4d8313 (2 hours ago), 2020-03-11 10:03:05 -0700 • Engine revision 0e2c8feeeb • Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)

    [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at C:\Users\memoo\AppData\Local\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 28.0.3 • Java binary at: D:\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.

    [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

    [√] Android Studio (version 3.6) • Android Studio at D:\Android Studio • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

    [√] VS Code (version 1.42.1) • VS Code at C:\Users\memoo\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.8.1

    [√] Connected device (3 available) • SM A505F • RZ8M74QGHPW • android-arm64 • Android 9 (API 28) • Chrome • chrome • web-javascript • Google Chrome 80.0.3987.132 • Web Server • web-server • web-javascript • Flutter Tools

    • No issues found!

    opened by mehmet-hakan-yazkan 7
  • UI界面异常

    UI界面异常

    在本人的魅族m2 note和小米NOTE LTE都会出现图中的界面异常现象 WechatIMG56

    本人代码

    DatePicker.showDatePicker(context,
                    showTitleActions: true,
                    maxTime: DateTime.now(),
                    minTime: DateTime(2000, 1, 1),
                    locale: LocaleType.zh,
                    onConfirm: (DateTime date) {
                      _timeString = DateFormat('yyyy-MM-dd').format(date);
                      _timestamp = date.millisecondsSinceEpoch;
                      print('timestamp is $_timestamp');
                      setState(() {});
                    }
                );
    
    opened by c007136 7
  • Realank#197 shadowThemeOnly is removed on flutter master

    Realank#197 shadowThemeOnly is removed on flutter master

    Refs #197; flutter/flutter#69050 recently removed Theme.of(context, shadowThemeOnly) and it recommends to use InheritedTheme.capture for applying shadowing-themes to widgets. Although InheritedTheme.capture is not available on stable/beta channel, we can still use InheritedTheme.captureAll for the purpose.

    opened by espresso3389 6
  • Allow to disable a column in a layout + time picker optional seconds

    Allow to disable a column in a layout + time picker optional seconds

    Hello, it's me again^^

    I noticed that a picker must have 3 columns, but in some case you may want only two (for example in a time picker without the seconds column). With this commit, setting a column's layout proportion to 0 will disable the column completely (without needing to do weird proportions like [100, 100, 1]).

    That created an opportunity for a "showSecondsColumn" property in the TimePickerModel that would enable/disable the seconds column, so I implemented it too. :) Apparently, this is a feature that is requested by several people: #61 #45

    Finally, I fixed the warnings created by my previous commit.

    Have a good day,

    Martin

    opened by martin-danhier 6
  • AM/PM?

    AM/PM?

    Can the plugin display AM/PM? I am looking to use the plugin to show hours, minutes and am/pm only. The documentation does not mention this, and I can't seem to see an option for it?

    opened by rgbinnovation 5
  • Revert

    Revert "Fix warning during initialization"

    Reverts Realank/flutter_datetime_picker#236

    Apparently DatePickerTheme was updated where backgroundColor is non-nullable, so now this PR created a warning instead of removing it.

    ./../../../.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.5.1/lib/flutter_datetime_picker.dart:311:32: Warning: Operand of null-aware operation '??' has type 'Color' which excludes
    null.
     - 'Color' is from 'dart:ui'.
                      color: theme.backgroundColor ?? Colors.white,
    
    opened by AlexHartford 4
  • # Task - Add the support to translate Arabic number as well:

    # Task - Add the support to translate Arabic number as well:

    Add a new string extension in date_format.dart file to convert numbers into Arabic numbers.

    Adding an extra padding for the confirm and cancel button for the case of RTL.

    Editing the example by adding a new choice of the Arabic version.

    opened by nabil-hfz 0
  • Validating the Date Picker

    Validating the Date Picker

    Is there a way we can validate the date picker? For example, if there's an initial value of "A", it is possible to validate the date picker that is wrapped under the Text button, that is selected value is "A", then it should not continue the work flow...

    opened by tahaaslam1 0
  • Add Amharic localization

    Add Amharic localization

        Update AM language month list
    

    Originally posted by @BeleShew in https://github.com/Realank/flutter_datetime_picker/pull/308#pullrequestreview-1129395238

    opened by BeleShew 0
Owner
Realank
iOS Developer / Google Developer Expert in Flutter
Realank
Flutter Date & Time Range Picker

F-DateTimeRangePicker Date and Time Range Picker for Flutter Installing: dependencies: f_datetimerangepicker: ^0.2.0 Using: import 'package:f_datet

Long Phan 20 Jan 18, 2022
A DateTime picker that lets user to select a date and the time, with start & end as a range

Omni DateTime Picker A DateTime picker that lets user to select a date and the time, with start & end as a range. Screenshots Getting started Add this

null 17 Dec 29, 2022
Allows to use date pickers without dialog. Provides some customizable styles for date pickers.

flutter_date_pickers Allows to use date pickers without dialog. Provides some customizable styles for date pickers. A set of date pickers: DayPicker f

null 196 Dec 29, 2022
A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Numbers, Nepali Unicode, Nepali Moments and many more.

Nepali Utilities for Dart A pure dart package with collection of Nepali Utilities like Date converter, Date formatter, DateTime, Nepali Number, Nepali

Sarbagya Dhaubanjar 23 Nov 22, 2022
A Flutter package for adding a DateRange widget into a form. A date picker UX is provided by showDateRangePicker.

A Flutter package for adding a DateRange widget into a form. A date picker UX is provided by showDateRangePicker.

JMA Consulting 9 Mar 12, 2022
Flutter Date Picker Library that provides a calendar as a horizontal timeline.

DatePickerTimeline Flutter Date Picker Library that provides a calendar as a horizontal timeline. How To Use Import the following package in your dart

LiLi 0 Oct 25, 2021
Flutter Cupertino Date Picker

Flutter Cupertino Date Picker [pub packages] | 中文说明 Flutter cupertino date picker. Usage 1. Depend Add this to you package's pubspec.yaml file: depend

Ryuuzaki 0 Nov 9, 2021
Flutter Date Picker Library that provides a calendar as a horizontal timeline

Flutter Date Picker Library that provides a calendar as a horizontal timeline.

Vivek Kaushik 214 Jan 7, 2023
Beautiful Date Range Picker Dialog For Flutter

Beautiful Date Range Picker Dialog For Flutter

Mazouzi Aymene 36 Dec 22, 2022
A persian (farsi,shamsi) datetime picker for flutter, inspired by material datetime picker.

?? A persian (farsi,shamsi) datetime picker for flutter, inspired by material datetime picker. Persian datetime picker inspired by material datetime p

Persian Flutter Community 142 Dec 19, 2022
A day night time picker for Flutter. Beautiful day and night animation with Sun and Moon assets.

DayNightTimePicker A day night time picker for Flutter with Zero Dependencies. Default style: IOS style: View it on pub.dev Installation Add to pubspe

Subhamay Dutta 68 Dec 29, 2022
A Custom Time Interval Select Dropdown for getting a Time Range

time_interval_picker A Custom Time Interval Select Dropdown for getting a Time R

Anurag Bansal 2 Apr 13, 2022
Flutter package to create a day date scroller

scrolling_day_calendar A flutter calendar package to allow users to scroll through given dates either by swiping left and right or pressing the arrows

null 8 Jul 12, 2020
CalendarDatePicker2 - A lightweight and customizable calendar picker based on Flutter CalendarDatePicker

A lightweight and customizable calendar picker based on Flutter CalendarDatePicker, with support for single date picker, range picker and multi picker.

Neo Liu 27 Dec 22, 2022
a time planner for flutter to show task on table

A beautiful, easy to use and customizable time planner for flutter mobile ?? , desktop ?? and web ??

Mohammad Jamalianpour 150 Dec 21, 2022
Calendar widget for flutter

Calendar Shows a scrolling calendar list of events. This is still relatively basic, it always assumes that the getEvents returns the entire list of ca

null 223 Dec 19, 2022
Calendar widget for flutter that is swipeable horizontally. This widget can help you build your own calendar widget highly customizable.

flutter_calendar_carousel Calendar widget for flutter that is swipeable horizontally. This widget can help you build your own calendar widget highly c

dooboolab 750 Jan 7, 2023
Highly customizable, feature-packed calendar widget for Flutter

Table Calendar Highly customizable, feature-packed Flutter Calendar with gestures, animations and multiple formats. Table Calendar with custom styles

Aleksander Woźniak 1.5k Jan 7, 2023
A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

A Flutter package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) dates.

Amirreza Madani 63 Dec 21, 2022