list - 将 where 方法与 List 一起使用
问题描述
我在颤动中遇到问题我想做一个搜索栏并且我对 api 有响应并且我想显示来自服务器的数据,其中包含来自搜索栏的文本我的问题是方法不适用于列出任何想法?
解决方案
查看您的评论,没有where
关于String
类型的方法。而不是for
循环,你想要一些类似的东西:
// Remove the for loop
// for(var i = 0; i <map.length; i++) { _results = jsonDecode(map[i]['address']).where((p)=>p.startsWith(query)).toList(); }
// Do this instead
_results = map.where((item) => item['address'].startsWith(query)).toList();
您现在应该可以放弃 for 循环了。
推荐阅读
- sql - 带有运行总计的 SQL 月度预算查询
- python - Python Selenium 找不到元素标题(xpath)
- spring-boot - 带有弹簧启动的 JMS,发送者和接收者在同一个包上:它有什么用?
- node.js - 使用本机节点模块发送表单数据
- validation - 为什么 Lua 不重新评估 io.read("*n")?
- vba - 根据列表值隐藏/取消隐藏某些行
- google-cloud-platform - 如何限制 Google Pub/Sub 中 Publisher 上的线程数?
- python - Kivy 打开两个弹出窗口,而我只期望一个
- ubuntu - SSL 证书不适用于 Ubuntu 16.04 上的 localhost
- ionic-framework - 如何在 Ionic App 中更改原色