📜  使用搜索委托颤振 firebase - Dart 代码示例

📅  最后修改于: 2022-03-11 14:48:06.838000             🧑  作者: Mango

代码示例1
Widget buildSuggestions(BuildContext context) {
  return StreamBuilder(
    stream: Firestore.instance.collection('todos').snapshots(),
    builder: (context, snapshot) {
      if (!snapshot.hasData) return new Text('Loading...');

      final results =
          snapshot.data.documents.where((a) => a['title'].contains(query));

      return ListView(
        children: results.map((a) => Text(a['title'])).toList(),
      );
    },
  );
}