flutter_cupertino_date_picker 0.0.7

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

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: ^0.0.7

2. Install

Run command:

$ flutter packages get

3. Import

Import in Dart code:

import 'packages:flutter_cupertino_date_picker/flutter_cupertino_date_picker.dart';

4. Display DatePicker

///
/// context: BuildContext.
/// showTitleActions: Display confirm and cancel button in title bar or not.
/// local: i18n, 'zh' for Chinese, default is English.
/// minYear: Min value of year's selection range. Default is 1900.
/// maxYear: Max value of year's selection range. Default is 2100.
/// initialYear: Initial value of year.
/// initialMonth: Initial value of month.
/// initialDate: Initial value of date.
/// dateFormat: Format English months.
/// onChange: An option callback when the currently selected datetime changes.
/// onConfirm: An option callback when tap the confirm button in title bar.
DatePicker.showDatePicker(
  context,
  showTitleActions: true,
  locale: 'zh',
  minYear: 1970,
  maxYear: 2020,
  initialYear: 2018,
  initialMonth: 6,
  initialDate: 21,
  dateFormat: 'yyyy-mm-dd'
  onChanged: (year, month, date) { },
  onConfirm: (year, month, date) { },
);

showTitleActions: false

Example: showTitleActions=false

locale: 'zh'

i18n, default is English

Thanks to: Robbie Boyd

Example: locale=zh

dateFormat: 'yyyy-mmm-dd'

Just support English months.

It will also put the Pickers in the same order. The date String output does not change

dd-mm-yyyy -> 1-10-2018
dd-mmm-yyyy -> 1-Oct-2018
dd-mmmm-yyyy -> 1-October-2018

Example: dateFormat

Example #

Example sources

Futures #

  1. Format datetime display.

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.

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/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_cupertino_date_picker/flutter_cupertino_date_picker.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Date Picker Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _datetime = '';
  int year = 2018;
  int month = 9;
  int date = 3;

  /// Display date picker.
  void _showDatePicker() {
    final bool showTitleActions = false;
    DatePicker.showDatePicker(
      context,
      showTitleActions: showTitleActions,
      minYear: 1970,
      maxYear: 2020,
      initialYear: year,
      initialMonth: month,
      initialDate: date,
      locale: 'en',
      dateFormat: 'yyyy-mmm-dd',
      onChanged: (year, month, date) {
        print('onChanged date: $year-$month-$date');

        if (!showTitleActions) {
          settingDatetime(year, month, date);
        }
      },
      onConfirm: (year, month, date) {
        settingDatetime(year, month, date);
      },
    );
  }

  void settingDatetime(int year, int month, int date) {
    setState(() {
      this.year = year;
      this.month = month;
      this.date = date;
      _datetime = '$year-$month-$date';
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Date Picker Demo'),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text(
              'Selected Date:',
              style: Theme.of(context).textTheme.subhead,
            ),
            new Text(
              '$_datetime',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: _showDatePicker,
        tooltip: 'DatePicker',
        child: new Icon(Icons.date_range),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_cupertino_date_picker: ^0.0.7

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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.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
0.2.0 Nov 29, 2018 Go to the documentation of flutter_cupertino_date_picker 0.2.0 Download flutter_cupertino_date_picker 0.2.0 archive
0.1.0 Nov 13, 2018 Go to the documentation of flutter_cupertino_date_picker 0.1.0 Download flutter_cupertino_date_picker 0.1.0 archive

All 18 versions...

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

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

  • Dart: 2.3.0
  • pana: 0.12.15
  • Flutter: 1.5.8

Platforms

Detected platforms:

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running flutter packages pub upgrade failed with the following output:

ERR: The current Flutter SDK version is 1.5.8.
 
 Because flutter_cupertino_date_picker requires Flutter SDK version >=0.4.1 <1.0.0, version solving failed.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0