小编ste*_*uke的帖子

使用Cloud Firestore创建无限列表

我目前正在将Cloud Firestore与Streambuilder小部件一起使用,以便使用Firestore文档填充ListView小部件.

new StreamBuilder<QuerySnapshot>(
  stream: Firestore.instance.collection('videos').limit(10).snapshots(),
  builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
    if (!snapshot.hasData) return new Center(
      child: new CircularProgressIndicator(),
    );
    return new ListView(
      children: snapshot.data.documents.map((DocumentSnapshot document) {
        new Card(child: ...)
      }).toList(),
    );
  },
);
Run Code Online (Sandbox Code Playgroud)

然而,此设置仅允许查询前x个结果(在这种情况下x = 10),其中x是固定数字,用户希望看到的卡片小部件的数量迟早会被超出或超过向下滚动.

现在是否可以查询前x个结果,并在用户点击滚动阈值后查询来自Cloud Firestore的下一个x + 10结果,依此类推?
这将允许动态列表长度,这也将有利于Firestore数据消耗.

dart flutter google-cloud-firestore

10
推荐指数
1
解决办法
1595
查看次数

Flutter构造函数错误

我尝试使用的代码段有问题,并且由于我是飞镖新手,所以我不太了解错误消息。有人可以向我解释为什么错误消息说

构造函数返回类型“ dynamic”,而不是预期类型“ widget”。

以及如何解决?

dart flutter

6
推荐指数
1
解决办法
4284
查看次数

标签 统计

dart ×2

flutter ×2

google-cloud-firestore ×1