date_field 0.3.1 date_field: ^0.3.1 copied to clipboard
Contains DateField and DateFormField which allows the user to pick a DateTime from an input field!
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>[
DateTimeField(
selectedDate: selectedDate,
onDateSelected: (DateTime date) {
setState(() {
selectedDate = date;
});
},
lastDate: DateTime(2020),
),
],
),
],
),
);
}
}