Open suggestions when focus on field
stefanop1 opened this issue · 1 comments
Thanks for this great library.
I am not sure if I missed this. It is possible to open the suggestions list when I go into field?
Hello @stefanop1! Yes you definitely can do this:
You just need two extra properties to test:
BoxController
and FocusNode
. Create and give them to your FieldSuggestion
widget.
final boxController = BoxController();
final focusNode = FocusNode();
Then initialize a listener for the focusNode
in initState:
focusNode.addListener(() {
boxController.show!();
// Also you can do something else here ...
});
If you're using the basic FieldSuggestion
(I mean without custom builder) it'd open just an empty box the first time.
So, something like that:
So, to avoid this weird behavior, basically, you can use custom builder (that's the best solution). Or do something like that:
Set custom search function to your FieldSuggestion
widget:
Which will always keep your box open until you close it.
customSearch: (_, __) => true,
And then convert your focusNode
's listener like:
focusNode.addListener(() {
boxController.show!();
textController.text = ' ';
});
The final result would be like that: