Date time dialog example:
new FormField(
builder: (FormFieldState<DateTime> field) {
return new Container(
padding: const EdgeInsets.only(top: 20.0),
child: new FlatButton(
textColor: Colors.black38,
child: new Row(
children: <Widget>[
new Container(
child: new Icon(Icons.calendar_today),
),
new Container(
padding: const EdgeInsets.only(left: 10.0),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
field.value != null
? "Date: ${new DateFormat('dd/MM/yyyy').format(field.value)}"
: "Date",
),
new Text(
field.errorText == null ? "" : field.errorText,
style: Theme.of(context).textTheme.caption.copyWith(color: Theme.of(context).errorColor)
)
],
),
)
],
),
onPressed: _onShowDataPicker,
),
);
},
validator: _onValidate
)
void _onShowDataPicker() {
showDatePicker(
context: context,
initialDate: new DateTime.now(),
firstDate: new DateTime(1930, 01, 01),
lastDate: new DateTime.now()
).then((date) {
_target.limitDate = date;
//setState(() => _limitDateText = );
});
}
String _onValidate(DateTime value) {
if(value == null)
return "Select a date";
return null;
}