【问题标题】:In flutter_typehead TypeAheadField widget, how do I customize the message letting user know there is no matching item found?在 flutter_typehead TypeAheadField 小部件中,如何自定义消息让用户知道没有找到匹配项?
【发布时间】:2021-04-16 22:21:11
【问题描述】:

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

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

【问题讨论】:

    标签: flutter dart autocomplete flutter-typeahead


    【解决方案1】:

    TypeAheadFormField 提供了一个回调,可用于自定义消息“未找到项目”。我在文档中没有看到这个,但它是可用的。回调是:noItemsFoundBuilder

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

    TypeAheadFormField(
              textFieldConfiguration: TextFieldConfiguration(
                  controller:
                  decoration: 
                  )),
              itemBuilder: (context, suggestion) {
                return ListTile(
                  title: Text(''),
                );
              },
              noItemsFoundBuilder: (value) {
                var localizedMessage = "Parlez-vous Français!";
                return Text(localizedMessage);
              }, )
    

    【讨论】:

      猜你喜欢
      • 2019-11-19
      • 2020-04-17
      • 1970-01-01
      • 2021-02-02
      • 2013-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多