flutter_datetime_picker 1.2.6

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:

  • English(en)
  • Persian(fa)
  • Chinese(zh)
  • Dutch(nl)
  • Russian(ru)
  • Italian(it)
  • French(fr)
  • Spanish(es)
  • Polish (pl)
  • Portuguese(pt)
  • Korean(ko)
  • Arabic(ar)
  • Turkish(tr)
  • Japanese(jp)
  • German(de)
  • Danish(da)
  • Bengali(bn)
  • Vietnamese(vi)
  • Armenian(hy)
  • Indonesian(id)
  • Bulgarian(bg)

and you can also custom your own picker content

Date pickerTime pickerDate Time picker

International:

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

Demo App #

main page

Usage #

FlatButton(
    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:

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<int> 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.

[0.1.0] - initial submit

[0.1.1] - add time picker and date time picker, add i18n

[0.1.2] - fix bugs

[0.1.3] - fix bugs

[0.1.4] - change screenshot path

[0.1.5] - change screenshot path

[0.1.6] - sync

[0.1.7] - pub.dartlang.org bug, re-submit

[0.1.8] - update description

[0.1.9] - update description

[0.1.10] - update description

[1.0.0] - release stable version

[1.0.1] - fix day bug when changing month

[1.0.2] - add Dutch support

[1.0.3] - add Dutch in demo

[1.0.4] - add Dutch in readme

[1.0.5] - add max/min time limit for Date Picker, add theme

[1.0.6] - add comments

[1.0.7] - fix max/min time for datetime type picker

[1.0.8] - add Russian

[1.0.9] - fix readme

[1.1.0] - fix readme

[1.1.1] - add 3 more languages

[1.1.2] - add Portuguese

[1.1.3] - update date picker format

[1.1.4] - add 2 more languages

[1.1.5] - add Japanese

[1.1.6] - update something

[1.1.7] - update something

[1.1.8] - update something

[1.1.9] - add German

[1.2.0] - add support for time zone

[1.2.1] - add more languages

[1.2.2] - add customize example

[1.2.3] - fix confirm pop issue

[1.2.4] - fix format

[1.2.5] - add more languages

[1.2.6] - add more languages

example/README.md

example #

A demo for flutter_datetime_picker

Getting Started #

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

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_datetime_picker: ^1.2.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
98
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
99
Learn more about scoring.

We analyzed this package on Sep 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test