firebase - 我如何添加加载圆形图标,因为从Firestore提取数据需要时间?

标签 firebase flutter dart google-cloud-firestore stream-builder

I want to show a loading button until it loads all the list items from firestore.

return StreamBuilder(
         
        stream: Firestore.instance.collection(uid).snapshots(),
        
        builder: (context, snapshot) {
          if (snapshot.hasData) {
          
          return ListView.builder(
            itemBuilder: (ctx, index) {
              return FavItem(
                uid: snapshot.data.documents[index]['uid'],
                id: snapshot.data.documents[index]['id'],
         , 
                
                
              );
            },
            itemCount: snapshot.data.documents.length,
          

最佳答案

CircularProgressIndicator可能就是您想要的。

StreamBuilder(
      stream: Firestore.instance.collection(uid).snapshots(),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return ...;
        }
        if (snapshot.hasError) {
          return Text(snapshot.error.toString());
        }
        return CircularProgressIndicator();
      },
    );

关于firebase - 我如何添加加载圆形图标,因为从Firestore提取数据需要时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62579251/

相关文章:

database - "MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)"当我使用楼层数据库时

android - Flutter path_provider错误-无法解析项目:path_provider_linux

dart - Flutter - 如何更改选定的文本颜色?

flutter - 弹出堆栈后如何调用initstate或didchangedependencies

ios - Firestore在文档中的数组中搜索字符串

android - Firebase Analytics 未显示 Android 应用的每日活跃用户

api - 如何从 Asp.net 核心向 Flutter 应用程序发送推送通知

java - Firebase - 新依赖项 - 问题 : NoClassDefFoundError: Failed resolution (QueryListenOptions)

javascript - 如何从引用中获取参数

dart - 如何插入具有关系的记录