| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import 'package:flutter/material.dart';
- import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
- void main() => runApp(new MyApp());
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return new MaterialApp(
- title: 'Flutter Demo',
- theme: new ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: new HomePage(),
- );
- }
- }
- class HomePage extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('Datetime Picker'),
- ),
- body: Center(
- child: Column(
- children: <Widget>[
- FlatButton(
- onPressed: () {
- DatePicker.showDatePicker(context,
- showTitleActions: true,
- minTime: DateTime(2018, 3, 5),
- maxTime: DateTime(2019, 6, 7),
- theme: DatePickerTheme(
- backgroundColor: Colors.blue,
- itemStyle: TextStyle(
- color: Colors.white, fontWeight: FontWeight.bold),
- doneStyle:
- TextStyle(color: Colors.white, fontSize: 16)),
- onChanged: (date) {
- print('change $date');
- }, onConfirm: (date) {
- print('confirm $date');
- }, currentTime: DateTime.now(), locale: LocaleType.en);
- },
- child: Text(
- 'show date picker(custom theme &date time range)',
- style: TextStyle(color: Colors.blue),
- )),
- FlatButton(
- onPressed: () {
- DatePicker.showTimePicker(context, showTitleActions: true,
- onChanged: (date) {
- print('change $date');
- }, onConfirm: (date) {
- print('confirm $date');
- }, currentTime: DateTime(2008, 12, 31, 23, 12, 34));
- },
- child: Text(
- 'show time picker',
- style: TextStyle(color: Colors.blue),
- )),
- FlatButton(
- onPressed: () {
- DatePicker.showDateTimePicker(context, showTitleActions: true,
- onChanged: (date) {
- print('change $date');
- }, onConfirm: (date) {
- print('confirm $date');
- },
- currentTime: DateTime(2008, 12, 31, 23, 12, 34),
- locale: LocaleType.zh);
- },
- child: Text(
- 'show date time picker (Chinese)',
- style: TextStyle(color: Colors.blue),
- )),
- FlatButton(
- onPressed: () {
- DatePicker.showDateTimePicker(context, showTitleActions: true,
- onChanged: (date) {
- print('change $date');
- }, onConfirm: (date) {
- print('confirm $date');
- }, currentTime: DateTime(2008, 12, 31, 23, 12, 34));
- },
- child: Text(
- 'show date time picker (English-America)',
- style: TextStyle(color: Colors.blue),
- )),
- FlatButton(
- onPressed: () {
- DatePicker.showDateTimePicker(context, showTitleActions: true,
- onChanged: (date) {
- print('change $date');
- }, onConfirm: (date) {
- print('confirm $date');
- },
- currentTime: DateTime(2008, 12, 31, 23, 12, 34),
- locale: LocaleType.nl);
- },
- child: Text(
- 'show date time picker (Dutch)',
- style: TextStyle(color: Colors.blue),
- )),
- FlatButton(
- onPressed: () {
- DatePicker.showDateTimePicker(context, showTitleActions: true,
- onChanged: (date) {
- print('change $date');
- }, onConfirm: (date) {
- print('confirm $date');
- },
- currentTime: DateTime(2008, 12, 31, 23, 12, 34),
- locale: LocaleType.ru);
- },
- child: Text(
- 'show date time picker (Russian)',
- style: TextStyle(color: Colors.blue),
- )),
- ],
- ),
- ),
- );
- }
- }
|