Flutter Cupertino 日期选择器

Flutter Cupertino 日期选择器。

Flutter-Cupertino-Date-Picker

用法

1. 依赖

将此添加到您的 package 的 pubspec.yaml 文件中

dependencies:
  flutter_cupertino_date_picker: ^0.0.7

2. 安装

运行命令

$ flutter packages get

3. 导入

在 Dart 代码中导入

import 'packages:flutter_cupertino_date_picker/flutter_cupertino_date_picker.dart';

4. 显示日期选择器

///
/// 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

flutter-cupertino-date-pickers

locale: 'zh'

国际化,默认为英语

感谢:Robbie Boyd

flutter-cupertino-date-pickerv

dateFormat: 'yyyy-mmm-dd'

仅支持英文月份。

它还会将选择器按相同顺序排列。日期字符串输出不变

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

flutter-cupertino-date-picker

示例

示例源码

功能

  1. 格式化日期时间显示。

许可证

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

   https://apache.ac.cn/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.

GitHub

https://github.com/wuzhendev/flutter-cupertino-date-picker