calculator and login improvements
This commit is contained in:
@@ -66,9 +66,26 @@ class _StationAutocompleteState extends State<StationAutocomplete> {
|
||||
fieldViewBuilder:
|
||||
(context, textEditingController, focusNode, onFieldSubmitted) {
|
||||
textEditingController.value = _controller.value;
|
||||
|
||||
return TextField(
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) {
|
||||
final query = textEditingController.text.toLowerCase();
|
||||
final matches = widget.allStations
|
||||
.map((s) => s.name)
|
||||
.where((name) => name.toLowerCase().contains(query))
|
||||
.toList();
|
||||
|
||||
if (matches.isNotEmpty) {
|
||||
matches.sort((a, b) => a.length.compareTo(b.length));
|
||||
final firstMatch = matches.first;
|
||||
_controller.text = firstMatch;
|
||||
widget.onChanged(firstMatch);
|
||||
focusNode.unfocus(); // optionally close keyboard
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Select station',
|
||||
border: OutlineInputBorder(),
|
||||
|
||||
Reference in New Issue
Block a user