toWidget method
Builds the current field into a Widget to be used for input in the side panel.
Implementation
@override
Widget toWidget(BuildContext context, String group, DateTime? value) {
return TextFormField(
initialValue: (value ?? initialValue)?.toSimpleFormat(),
keyboardType: TextInputType.datetime,
decoration: InputDecoration(
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today_rounded),
onPressed: () async {
final dateTime = await showDateTimePicker(
context,
value ?? initialValue,
);
if (dateTime == null) return;
updateField(
context,
group,
dateTime,
);
},
),
),
onChanged: (value) => updateField(
context,
group,
codec.toValue(value) ?? initialValue ?? DateTime.now(),
),
);
}