pubspec.yaml

flutter_cupertino_date_picker: ^1.0.

DatePicker.dart

import 'package:date_format/date_format.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cupertino_date_picker/flutter_cupertino_date_picker.dart';
class DatePickerPubDemo extends StatefulWidget {
DatePickerPubDemo({Key key}) : super(key: key);
_DatePickerPubDemoState createState() => _DatePickerPubDemoState();
} class _DatePickerPubDemoState extends State<DatePickerPubDemo> {
DateTime _dateTime=DateTime.now();
_showDatePicker(){
DatePicker.showDatePicker(
context,
pickerTheme: DateTimePickerTheme(
showTitle: true,
confirm: Text('确定',style:TextStyle(color:Colors.red)),
cancel: Text('取消',style: TextStyle(color: Colors.cyan)),
),
minDateTime: DateTime.parse("1980-05-21"),
maxDateTime: DateTime.parse("2019-05-21"),
initialDateTime: _dateTime,
// dateFormat: "yyyy-MMMM-dd", //只包含年、月、日
dateFormat: 'yyyy年M月d日 EEE,H时:m分',
pickerMode: DateTimePickerMode.datetime,
locale: DateTimePickerLocale.zh_cn,
onCancel: (){
debugPrint("onCancel");
},
onConfirm: (dateTime,List<int> index){
setState(() {
_dateTime=dateTime;
});
}
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('日期选中'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
child: Row(
children: <Widget>[
// Text("${formatDate(_dateTime,[yyyy,'年',mm,'月',dd])}"), //只获取年月日
Text("${formatDate(_dateTime,[yyyy,'年',mm,'月',dd,' ',HH,':',nn])}"),
Icon(Icons.arrow_drop_down)
],
),
onTap:_showDatePicker,
)
],
)
],
),
);
}
}

27flutter日期 时间组件flutter_cupertino_date_picker的使用的更多相关文章

  1. 日期时间组件 - layui.laydate

    全部参数 一.核心方法:laydate(options); options是一个对象,它包含了以下key: '默认值' { elem: '#id', //需显示日期的元素选择器 event: 'cli ...

  2. 如何在Rails6内通过Webpacker使用JavaScript; flatpicker日期时间组件选择器

    如何在Rails6内通过Webpacker使用JavaScript; Rails6默认不再使用asset pipeline,改用Webpacker. 文件结构变化: 配置文件: webpacker.y ...

  3. yii2超好用的日期组件和时间组件

    作者:白狼 出处:http://www.manks.top/yii2_datetimepicker.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接 ...

  4. 【Android 应用开发】Android - 时间 日期相关组件

    源码下载地址 : -- CSDN :  http://download.csdn.net/detail/han1202012/6856737 -- GitHub : https://github.co ...

  5. Android - 时间 日期相关组件

    源码下载地址 : -- CSDN :  http://download.csdn.net/detail/han1202012/6856737 -- GitHub : https://github.co ...

  6. 第二百一十九节,jQuery EasyUI,DateTimeBox(日期时间输入框)组件

    jQuery EasyUI,DateTimeBox(日期时间输入框)组件 学习要点: 1.加载方式 2.属性列表 3.方法列表 本节课重点了解 EasyUI 中 DateTimeBox(日期时间输入框 ...

  7. POCO库——Foundation组件之日期时间DateTime

    日期时间DateTime:内部提供多个设计计时器.日期.时区.时间戳等: Clock.h :Clock时钟计时类,_clock:Int64类型时钟值,CLOCKVAL_MIN.CLOCKVAL_MAX ...

  8. react-native DatePicker日期选择组件的实现

    本教程的实现效果如下: 为了实现其淡入/淡出的覆盖效果, 还有取消按钮, 在此用了一个三方的组件, 大家可以先安装一下: 三方组件的地址:https://github.com/eyaleizenber ...

  9. javascript学习之时间组件

    写了一个时间组件,哪里需要哪里调(菜鸟级别,大牛路过就Ok了): 先有一个HTML文件: <!doctype> <html> <head> <title> ...

随机推荐

  1. reGeorg+Proxifier使用

    reGeorg利用了socks5协议建立隧道,结合Proxifier可将目标内网代理出来. 项目地址: https://github.com/sensepost/reGeorg 该文件下支持php,a ...

  2. IDEA实用教程(二)

    2. 基础设置 1) 进入全局设置 2) 更改主题 3) 修改主题字体 4) 修改代码编辑区字体 5) 修改控制台字体 图中3处修改控制台字体 图中4处修改控制台字体 6) 文件编码的设置 图中4处建 ...

  3. ResNet网络的Pytorch实现

    1.文章原文地址 Deep Residual Learning for  Image Recognition 2.文章摘要 神经网络的层次越深越难训练.我们提出了一个残差学习框架来简化网络的训练,这些 ...

  4. SATB的标记问题解决之道与G1垃圾收集模式系统详解及最佳实践

    继续接着上一次https://www.cnblogs.com/webor2006/p/11148282.html的理论学习,上一次学习到了这: 接着继续: SATB详解: 对于三色算法在concurr ...

  5. linux网络编程之system v消息队列(二)

    今天继续学习system v消息队列,主要是学习两个函数的使用,开始进入正题: 下面则开始用代码来使用一下该发送函数: 在运行之前,先查看一下1234消息队列是否已经创建: 用上次编写的查看消息队列状 ...

  6. Gitlab,Mac下生成SSH Key

      git是分布式的代码管理工具,远程的代码管理是基于ssh的,所以要使用远程的git则需要ssh的配置.简单的说,Git - 版本控制工具:Github是一个网站,提供给用户空间创建git仓储,保存 ...

  7. aiohttp 支持异步的网络请求模块

    通常在进行网络数据采集时候我们会用到requests,urllib等模块,但是这些模块在使用中并不支持异步,所以今天我们介绍一个支持异步网络请求的模块aiohttp. 首先我们使用flask简单的搭一 ...

  8. Substring Anagrams

    Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings ...

  9. trigger 和 triggerHandler(),自定义事件

    trigger 和 triggerHandler(),自定义事件 语法: $(selector).trigger(event,[param1,param2,...]) 1,event 必需.规定指定元 ...

  10. JAVA的选择结构(二)

    1.switch选择结构:                        语法:                            switch (key) {                   ...