date_field/example/main.dart

48 lines
1 KiB
Dart

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) {
return MaterialApp(title: 'Example app', home: HomeWidget());
}
}
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>[
DateField(
selectedDate: selectedDate,
onDateSelected: (DateTime date) {
setState(() {
selectedDate = date;
});
},
lastDate: DateTime(2020),
),
],
),
],
),
);
}
}