在 flutter_typehead TypeAheadField 小部件中,如何自定义消息让用户知道没有找到匹配的项目?

GMC*_*GMC 1 autocomplete dart flutter flutter-typeahead

我正在尝试使用此模块https://github.com/AbdulRahmanAlHamali/flutter_typeahead来创建具有自动完成/“提前输入”功能的文本字段。

当用户在文本字段表单中搜索项目但未找到该项目时,会返回“未找到项目”消息。如何出于本地化目的自定义此消息?

小智 6

TypeAheadFormField提供了一个回调,可用于自定义消息“No Item Found” 我没有在文档中看到这一点,但它可用。回调是:noItemsFoundBuilder

\n

这是使用此回调的示例代码:

\n
TypeAheadFormField(\n          textFieldConfiguration: TextFieldConfiguration(\n              controller:\n              decoration: \n              )),\n          itemBuilder: (context, suggestion) {\n            return ListTile(\n              title: Text(''),\n            );\n          },\n          noItemsFoundBuilder: (value) {\n            var localizedMessage = "Parlez-vous Fran\xc3\xa7ais!";\n            return Text(localizedMessage);\n          }, )\n
Run Code Online (Sandbox Code Playgroud)\n