CrySelectDate constructor
CrySelectDate(
- BuildContext context, {
- Key? key,
- String? value,
- String? label,
- ValueChanged? onChange,
- FormFieldSetter? onSaved,
Implementation
CrySelectDate(
BuildContext context, {
Key? key,
String? value,
String? label,
ValueChanged? onChange,
FormFieldSetter? onSaved,
}) : super(
key: key,
label: label,
builder: (CryFormFieldState state) {
return TextFormField(
readOnly: true,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(horizontal: 10),
border: OutlineInputBorder(),
),
controller: TextEditingController(text: value),
onChanged: (v) {
if (onChange != null) {
onChange(v);
}
},
onTap: () async {
final DateTime picked = (await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2015, 8),
lastDate: DateTime(2101),
))!;
value = formatDate(picked, [yyyy, '-', mm, '-', dd]);
state.didChange();
},
onSaved: (v) {
if (onSaved != null) {
onSaved(v);
}
},
);
},
);