Streambuilder 在 firestore 更改时不更新

Streambuilder not updating when firestore changes

我有一个动画列表,构建函数包含在应用程序主体的堆栈中。 每当数据库中有更新时,streambuilder 不会重建.. items 由以下函数在 init 中设置:

  Stream<List<Task>> getTasks(){
    try {
      Firestore.instance
          .collection("lists")
          .document(tasklist.postID)
          .collection("tasks")
          .snapshots();
    }
    on Exception {
      error();
    }
    return ref.snapshots().map((list) =>
        list.documents.map((doc) => Task.fromFireStore(doc)).toList());
}
  Widget _buildTasksList() {
    return new Expanded(
      child: new StreamBuilder(
      stream: items,
      builder: (BuildContext context, AsyncSnapshot snapshot) {
        if (!snapshot.hasData) {
          return new Text("Loading");
        }
        return new AnimatedList(
          initialItemCount: tasks.length,
          key: _listKey,
          itemBuilder: (context, index, animation) {
            print(index);
            return new TaskRow(
              task: listModel[index],
              animation: animation,
              listModel: listModel,
              tasklist: tasklist,
              onChange: () => _onChange(listModel[index]),
            );
          },
        );
      },
    )
    );
  }

initialItemCount 错误,应该是 items.length