flutter_cupertino_date_picker 1.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 97

Flutter Cupertino Date Picker #

[pub packages] | 中文说明

Flutter cupertino date picker.

Example

Usage #

1. Depend

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

dependencies:
  flutter_cupertino_date_picker: ^1.0.2

2. Install

Run command:

$ flutter packages get

3. Import

Import in Dart code:

import 'package:flutter_cupertino_date_picker/flutter_cupertino_date_picker.dart';

4. Display DatePicker

Bottom Sheet DatePicker #
/// Display date picker in bottom sheet.
///
/// context: [BuildContext]
/// minDateTime: [DateTime] minimum date time
/// maxDateTime: [DateTime] maximum date time
/// initialDateTime: [DateTime] initial date time for selected
/// dateFormat: [String] date format pattern
/// locale: [DateTimePickerLocale] internationalization
/// pickerMode: [DateTimePickerMode] display mode: date(DatePicker)、time(TimePicker)、datetime(DateTimePicker)
/// pickerTheme: [DateTimePickerTheme] the theme of date time picker
/// onCancel: [DateVoidCallback] pressed title cancel widget event
/// onChange: [DateValueCallback] selected date time changed event
/// onConfirm: [DateValueCallback] pressed title confirm widget event
DatePicker.showDatePicker(
  BuildContext context,
  DateTime minDateTime,
  DateTime maxDateTime,
  DateTime initialDateTime,
  String dateFormat,
  DateTimePickerLocale locale: DATETIME_PICKER_LOCALE_DEFAULT,
  DateTimePickerMode pickerMode: DateTimePickerMode.date,
  DateTimePickerTheme pickerTheme: DatePickerTheme.Default,
  DateVoidCallback onCancel,
  DateValueCallback onChange,
  DateValueCallback onConfirm,
});
DatePicker Widget #
/// Display date picker widget.
///
/// minDateTime: [DateTime] minimum date time
/// maxDateTime: [DateTime] maximum date time
/// initialDateTime: [DateTime] initial date time for selected
/// dateFormat: [String] date format pattern
/// locale: [DateTimePickerLocale] internationalization
/// pickerTheme: [DateTimePickerTheme] the theme of date time picker
/// onCancel: [DateVoidCallback] pressed title cancel widget event
/// onChange: [DateValueCallback] selected date time changed event
/// onConfirm: [DateValueCallback] pressed title confirm widget event
DatePickerWidget({
  DateTime minDateTime,
  DateTime maxDateTime,
  DateTime initialDateTime,
  String dateFormat: DATETIME_PICKER_DATE_FORMAT,
  DateTimePickerLocale locale: DATETIME_PICKER_LOCALE_DEFAULT,
  DateTimePickerTheme pickerTheme: DatePickerTheme.Default,
  DateVoidCallback onCancel,
  DateValueCallback onChange,
  DateValueCallback onConfirm,
})
TimePicker Widget #
/// Display time picker widget.
///
/// minDateTime: [DateTime] minimum date time
/// maxDateTime: [DateTime] maximum date time
/// initialDateTime: [DateTime] initial date time for selected
/// dateFormat: [String] date format pattern
/// locale: [DateTimePickerLocale] internationalization
/// pickerTheme: [DateTimePickerTheme] the theme of date time picker
/// onCancel: [DateVoidCallback] pressed title cancel widget event
/// onChange: [DateValueCallback] selected date time changed event
/// onConfirm: [DateValueCallback] pressed title confirm widget event
TimePickerWidget({
  DateTime minDateTime,
  DateTime maxDateTime,
  DateTime initialDateTime,
  String dateFormat: DATETIME_PICKER_DATE_FORMAT,
  DateTimePickerLocale locale: DATETIME_PICKER_LOCALE_DEFAULT,
  DateTimePickerTheme pickerTheme: DatePickerTheme.Default,
  DateVoidCallback onCancel,
  DateValueCallback onChange,
  DateValueCallback onConfirm,
})
DateTimePicker Widget #
/// Display date time picker widget.
///
/// minDateTime: [DateTime] minimum date time
/// maxDateTime: [DateTime] maximum date time
/// initialDateTime: [DateTime] initial date time for selected
/// dateFormat: [String] date format pattern
/// locale: [DateTimePickerLocale] internationalization
/// pickerTheme: [DateTimePickerTheme] the theme of date time picker
/// onCancel: [DateVoidCallback] pressed title cancel widget event
/// onChange: [DateValueCallback] selected date time changed event
/// onConfirm: [DateValueCallback] pressed title confirm widget event
DateTimePickerWidget({
  DateTime minDateTime,
  DateTime maxDateTime,
  DateTime initialDateTime,
  String dateFormat: DATETIME_PICKER_DATE_FORMAT,
  DateTimePickerLocale locale: DATETIME_PICKER_LOCALE_DEFAULT,
  DateTimePickerTheme pickerTheme: DatePickerTheme.Default,
  DateVoidCallback onCancel,
  DateValueCallback onChange,
  DateValueCallback onConfirm,
})

5. DateTimePickerLocale

Support:

  • en_us: English (EN) United States [Default locale]
  • zh_cn: Chinese (ZH) Simplified
  • pt_br: Portuguese (PT) Brazil
  • es: Spanish (ES)
Add more language #

Fork this project, add language text in lib/date_picker_i18n.dart file.

/// Done widget's text
const Map<DateTimePickerLocale, String> DONE = { ... };

/// Cancel widget's text
const Map<DateTimePickerLocale, String> CANCEL = { ... };

/// en_US
const List<String> EN_US_MONTHS = [ ... ];

/// en_US weeks with full name
const List<String> EN_US_WEEKS_FULL = [ ... ];

/// en_US weeks with short name
const List<String> EN_US_WEEKS_SHORT = [ ... ];

6. dateFormat

PatternMeaninge.g.
yyyyyear2019, 2020
yyyear, 2 digits19, 20
MMMMmonthJanuary(en_us), 01(zh_cn)
MMMmonth, abbreviatedJan(en_us), 01(zh_cn)
MMmonth, 2 digits01、11
Mmonth1, 11
ddday in month, 2 digits05, 25
dday in month5, 25
EEEEday of weekMonday(en_us), 星期一(zh_cn)
EEEday of week, abbreviatedMon(en_us), 周一(zh_cn)
HHhour (0~23), 2 digits04, 12, 20
Hhour (0~23)4, 12, 20
mmminute, 2 digits05, 40
mminute5, 40
sssecond, 2 digits06, 55
ssecond6, 55
yyyy年format2019年, 2020年
H时format5时, 21时
Date Format Separator #

Support separator: |,-._:.

7. DateTimePickerTheme

/// DateTimePicker theme.
///
/// [backgroundColor] DatePicker's background color.
/// [cancelTextStyle] Default cancel widget's [TextStyle].
/// [confirmTextStyle] Default confirm widget's [TextStyle].
/// [cancel] Custom cancel widget.
/// [confirm] Custom confirm widget.
/// [title] Custom title widget. If specify a title widget, the cancel and confirm widgets will not display. Must set [titleHeight] value for custom title widget.
/// [showTitle] Whether display title widget or not. If set false, the default cancel and confirm widgets will not display, but the custom title widget will display if had specified one custom title widget.
/// [pickerHeight] The value of DatePicker's height.
/// [titleHeight] The value of DatePicker's title height.
/// [itemHeight] The value of DatePicker's column height.
/// [itemTextStyle] The value of DatePicker's column [TextStyle].
const DateTimePickerTheme({
  this.backgroundColor: DATETIME_PICKER_BACKGROUND_COLOR,
  this.cancelTextStyle,
  this.confirmTextStyle,
  this.cancel,
  this.confirm,
  this.title,
  this.showTitle: DATETIME_PICKER_SHOW_TITLE_DEFAULT,
  this.pickerHeight: DATETIME_PICKER_HEIGHT,
  this.titleHeight: DATETIME_PICKER_TITLE_HEIGHT,
  this.itemHeight: DATETIME_PICKER_ITEM_HEIGHT,
  this.itemTextStyle: DATETIME_PICKER_ITEM_TEXT_STYLE,
});

Example #

Example sources

Example APK

Example APK Download

DatePicker #

Example: DatePicker

Example: DatePickerWidget

TimePicker #

Example: TimePicker

Example: TimePickerWidget

DateTimePicker #

Example: DateTimePicker

Example: DateTimePickerWidget

License #

Copyright 2018 wuzhen

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

1.0.2 #

  • Added Arabic language support.

1.0.1 #

  • Added Bengali language support.

1.0.0 #

  • Refactor code.
  • Support DatePickerTimePickerDateTimePicker.
  • Support DatePickerWidgetTimePickerWidgetDateTimePickerWidget.
  • Upgrade date format.
  • Add DateTimePickerTheme.
  • Add DateTimePickerLocale for locale.

0.8.0 #

  • Support set the value of minimum DateTime and maximum DateTime.

0.7.0 #

  • Change days in a month when moth changes.

0.6.0 #

  • Add DatePickerWidget widget for display DatePicker in page.

0.5.0 #

  • Add onChanged2(DateTime dateTime, List<int> selectedIndex) callback.
  • Add onConfirm2(DateTime dateTime, List<int> selectedIndex) callback.
  • Add minDateTime.
  • Add maxDateTime.
  • Add initialDateTime.

0.4.0 #

  • Add onCancel callback.

0.3.0 #

  • Support Flutter v1.0.

0.2.0 #

  • Add custom cancel and confirm button.

0.1.0 #

  • Refactor locale message.

0.0.7 #

  • Support locale Portuguese Brazil (pt-br)

0.0.6 #

  • Support English months.

0.0.5 #

  • Fix month and day in zh locale.

0.0.4 #

  • Support i18n.

0.0.2 #

  • Complete README file.

0.0.1 #

  • Initial Release.

example/README.md

Date Picker Example #

A Flutter application example of DatePicker.

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_cupertino_date_picker: ^1.0.2

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_cupertino_date_picker/flutter_cupertino_date_picker.dart';
  
Version Uploaded Documentation Archive
1.0.2 Jun 5, 2019 Go to the documentation of flutter_cupertino_date_picker 1.0.2 Download flutter_cupertino_date_picker 1.0.2 archive
1.0.1 Jun 5, 2019 Go to the documentation of flutter_cupertino_date_picker 1.0.1 Download flutter_cupertino_date_picker 1.0.1 archive
1.0.0+1 May 23, 2019 Go to the documentation of flutter_cupertino_date_picker 1.0.0+1 Download flutter_cupertino_date_picker 1.0.0+1 archive
1.0.0 May 23, 2019 Go to the documentation of flutter_cupertino_date_picker 1.0.0 Download flutter_cupertino_date_picker 1.0.0 archive
0.8.0 May 14, 2019 Go to the documentation of flutter_cupertino_date_picker 0.8.0 Download flutter_cupertino_date_picker 0.8.0 archive
0.7.0 May 13, 2019 Go to the documentation of flutter_cupertino_date_picker 0.7.0 Download flutter_cupertino_date_picker 0.7.0 archive
0.6.0 May 10, 2019 Go to the documentation of flutter_cupertino_date_picker 0.6.0 Download flutter_cupertino_date_picker 0.6.0 archive
0.5.0 May 9, 2019 Go to the documentation of flutter_cupertino_date_picker 0.5.0 Download flutter_cupertino_date_picker 0.5.0 archive
0.4.0 Apr 26, 2019 Go to the documentation of flutter_cupertino_date_picker 0.4.0 Download flutter_cupertino_date_picker 0.4.0 archive
0.3.0 Dec 5, 2018 Go to the documentation of flutter_cupertino_date_picker 0.3.0 Download flutter_cupertino_date_picker 0.3.0 archive

All 20 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
95
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
97
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/date_picker.dart.

Run flutter format to format lib/date_picker.dart.

Format lib/date_picker_constants.dart.

Run flutter format to format lib/date_picker_constants.dart.

Format lib/date_picker_i18n.dart.

Run flutter format to format lib/date_picker_i18n.dart.

Fix additional 6 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/date_picker_theme.dart (Run flutter format to format lib/date_picker_theme.dart.)
  • lib/date_picker_title_widget.dart (Run flutter format to format lib/date_picker_title_widget.dart.)
  • lib/date_picker_widget.dart (Run flutter format to format lib/date_picker_widget.dart.)
  • lib/date_time_formatter.dart (Run flutter format to format lib/date_time_formatter.dart.)
  • lib/datetime_picker_widget.dart (Run flutter format to format lib/datetime_picker_widget.dart.)
  • lib/time_picker_widget.dart (Run flutter format to format lib/time_picker_widget.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.

Dependencies

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