Flutter provides an Autocomplete widget. If I enter "abc" instead of selecting one of the suggestions, then how can I get this text "abc"?
CodePudding user response:
You can create another variable to hold the input String inside state class like String? _inputString; and update value inside optionsBuilder
class _AutocompleteBasicExampleState extends State<AutocompleteBasicExample> {
String? _inputString;
@override
Widget build(BuildContext context) {
return Autocomplete<String>(
optionsBuilder: (TextEditingValue textEditingValue) {
setState(() {
_inputString = textEditingValue.text;
});
