ListTile(
leading: Icon(Icons.access_time),
onTap: () async {
final TimeOfDay? picked = await showTimePicker(
context: context,
initialTime: _time,
);
if (picked != null) {
setState(() {
_eventTime.text = DateFormat('HH:mm').format(picked);
});
}
},
title: TextField(
readOnly: true,
controller: _eventTime,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Event Time",
),
),
),
I want to store the value of the selected time in the controller (_eventtime) to save in the firestore database
CodePudding user response:
You have to change mapping.
Change:
_eventTime.text = DateFormat('HH:mm').format(picked);
to:
_eventTime.text = DateFormat('HH:mm').format(DateTime(now.year, now.month, now.day, picked.hour, picked.minute));