datetime_picker_formfield 0.0.1
datetime_picker_formfield: ^0.0.1 copied to clipboard
A Flutter widget that wraps a TextFormField and integrates the date and/or time picker dialogs.
example/main.dart
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../lib/datetime_picker_formfield.dart';
import '../lib/time_picker_formfield.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Date-Time Picker example',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
MyHomePageState createState() {
return new MyHomePageState();
}
}
class MyHomePageState extends State<MyHomePage> {
final dateFormat = DateFormat("EEEE, MMMM d, yyyy 'at' h:mma");
final timeFormat = DateFormat("h:mm a");
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
DateTimePickerFormField(
format: dateFormat,
onChanged: (date) {
Scaffold
.of(context)
.showSnackBar(SnackBar(content: Text('$date')));
},
),
TimePickerFormField(
format: timeFormat,
onChanged: (time) {
Scaffold
.of(context)
.showSnackBar(SnackBar(content: Text('$time')));
},
),
DateTimePickerFormField(
format: dateFormat,
enabled: false,
),
TimePickerFormField(
format: toDateFormat(TimeOfDayFormat.HH_colon_mm),
enabled: false,
),
],
),
);
}
}