简体   繁体   English

如何在颤振中制作搜索过滤器

[英]How to make a search filter in flutter

So I'm using an API for the search filter which means that all the logic of the search filter is in the API, My job is to call the search filter API.所以我为搜索过滤器使用了一个 API,这意味着搜索过滤器的所有逻辑都在 API 中,我的工作是调用搜索过滤器 API。 I have tried to call the search API in the textfield on the onChange event.我试图在 onChange 事件的文本字段中调用搜索 API。 But the search API won't recognize any single alphabets on the textcontroller.但是搜索 API 不会识别文本控制器上的任何单个字母。 The Search perfectly works, I have tested it, but it didn't work when I display the list.搜索完美有效,我已经对其进行了测试,但是当我显示列表时它不起作用。

TextField(
          
             controller:searchQuery,
               onChanged:(string)
            {
                  setState(() {
                _provider.getSearch(searchQuery.toString());
              });
            },
            decoration: InputDecoration.collapsed(
            hintText: ''
           ),
          ),
         )

It's empty when I tried to search当我尝试搜索时它是空的当我尝试搜索时它是空的

It actually reads the input that I type when I debug,它实际上读取我在调试时输入的输入, 它实际上读取我输入的输入,当我调试时,

When I manually input the parameter it display all the list当我手动输入参数时,它会显示所有列表

Container(
           margin: EdgeInsets.symmetric(vertical: 10,horizontal: 10),
           child:TextField(
          
             controller:searchQuery,
               onChanged:(string)
            {
                  setState(() {
                _provider.getSearch("r");
              });
            },
            decoration: InputDecoration.collapsed(
            hintText: ''
           ),
          ),
         )

在此处输入图片说明

searchQuery.toString()searchQuery.text或使用 onChanged 方法的字符串变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM