如何解决我想建立搜寻列以按标题来撷取使用者文章
我已经为所有用户建立了一个搜索栏
当我将userList传递到搜索页面时,但是我不知道如何对诸如用户帖子等的documentSnapshot进行同样的操作。
9 Sept 2020 08:09:24
9 Sept 2020 08:11:00
9 Sept 2020 08:17:18
9 Sept 2020 08:17:18
9 Sept 2020 08:17:18
9 Sept 2020 08:17:18
9 Sept 2020 08:17:18
9 Sept 2020 08:17:18
9 Sept 2020 08:17:24
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:10
9 Sept 2020 08:31:24
9 Sept 2020 08:32:29
9 Sept 2020 08:33:28
解决方法
您可以这样使用'或'
Widget buildSuggestions(BuildContext context) {
final suggestionsList = query.isEmpty
? userList
: userList.where((p) => p.displayName.startsWith(query)).toList() || p.displayPost.startsWith(query)).toList();
return ListView.builder(
itemCount: suggestionsList.length,itemBuilder: ((context,index) => ListTile(
onTap: () {},leading: CircleAvatar(
backgroundImage: NetworkImage(suggestionsList[index].photoUrl),),title: Text(suggestionsList[index].displayName),)),);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。