I have added date range picker to my code. The user has to manually select save to choose the date range. I want the user to simply click the enter key and the range should be chosen. I cant seem to find any documentation on how to do this. I have inserted a screenshot of the UI of showDateRangePicker.
Screenshot of date time range picker
This is a snippet of my code
final _formKey = GlobalKey<FormState>();
void _validateForm() {
setState(() {
_formKey.currentState?.validate();
});
}
Future<void> _pickDateRange(BuildContext context) async {
final DateTimeRange? picked = await showDateRangePicker(
context: context,
firstDate: DateTime(2020),
lastDate: DateTime(2100),
initialDateRange: _dateRange,
);
if (picked != null) {
setState(() {
_dateRange = picked;
});
_validateForm();
}
}
I tried to use gesture detector but I’m not sure how to go about it.