首页 > 其他 > 详细

调用 flutter 第三方时间组件

时间:2020-02-24 14:56:51      阅读:114      评论:0      收藏:0      [点我收藏+]

https://pub.flutter-io.cn/packages/flutter_cupertino_date_picker

 

flutter_cupertino_date_picker: ^1.0.12

 

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

class DatePage extends StatefulWidget{
DatePage({Key key});
_DatePage createState() => _DatePage();
}

class _DatePage extends State {
_showDatePicker() {
DatePicker.showDatePicker(
context,
pickerTheme: DateTimePickerTheme(
showTitle: true,
confirm: Text(‘确定‘),
cancel: Text(‘取消‘)
),
minDateTime: DateTime.parse(‘2020-00-00‘),
maxDateTime: DateTime.parse(‘2030-00-00‘),
initialDateTime: DateTime.now(),
dateFormat: ‘yyyy-MM-dd HH:mm:ss‘,
locale: DateTimePickerLocale.zh_cn,
pickerMode: DateTimePickerMode.datetime,
onClose: () {
print(‘onClose‘);
},
onCancel: () {
print(‘onCancel‘);
},
onChange: (val, List<int> index) {
print(val);
print(index);
},
onConfirm: (val, List<int> index) {
print(val);
print(index);
},
);
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text(‘Date‘)
),
body: ListView(
children: <Widget>[
InkWell(
child: Column(
children: <Widget>[
SizedBox(height: 50,),
InkWell(
child: Text(‘${DateTime.now()}‘),
onTap: () {
_showDatePicker();
},
)
],
)
)
],
)
);
}
}

调用 flutter 第三方时间组件

原文:https://www.cnblogs.com/zhaofeis/p/12356789.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!