date_field/example/main.dart

49 lines
1 KiB
Dart
Raw Normal View History

2020-03-01 22:29:41 +00:00
import 'package:date_field/date_field.dart';
import 'package:flutter/material.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(ExampleApp());
}
class ExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
2020-03-01 22:34:26 +00:00
return MaterialApp(title: 'Example app', home: HomeWidget());
2020-03-01 22:29:41 +00:00
}
}
class HomeWidget extends StatefulWidget {
@override
_HomeWidgetState createState() => _HomeWidgetState();
}
class _HomeWidgetState extends State<HomeWidget> {
DateTime selectedDate;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Column(
children: <Widget>[
2020-07-19 14:49:06 +00:00
DateTimeField(
2020-03-01 22:29:41 +00:00
selectedDate: selectedDate,
onDateSelected: (DateTime date) {
setState(() {
selectedDate = date;
});
},
lastDate: DateTime(2020),
),
],
),
],
),
);
}
}