簡體   English   中英

如何獲取數組中的所有快照 flutter firebase 雲

[英]how to get snapshot all in an array flutter firebase cloud

我正在嘗試獲取所有數據信息。 在我的 firebase 雲火庫中,但我仍在努力使用代碼:

StreamBuilder<DocumentSnapshot?>(
  stream: FirebaseFirestore.instance
      .collection("groups")
      .doc(groupId)
      .snapshots(),
  builder: (context, snapshot) {
    return GridView.builder(
          gridDelegate:
          const SliverGridDelegateWithFixedCrossAxisCount(
       crossAxisCount: 2,
     ),

          itemBuilder: (context, index) {
            return SizedBox(
              child: snapshot.data!.get('members')[index][0],
              height: 20,
              width: 10,
            );
          });
  }),

在此處輸入圖像描述 我想拍攝所有這些並將其顯示在我的應用程序中

我認為我做的不對,因為這是我得到的錯誤

ErrorDescription('視口在滾動方向上展開以填充其容器。''在這種情況下,垂直視口被賦予了無限量的''垂直空間來展開。這種情況通常發生在''嵌套可滾動小部件時在另一個可滾動的小部件內。',

您正在添加一個不需要的[0]

改變:

snapshot.data!.get('members')[index][0],

至:

snapshot.data!.get('members')[index],

請注意,我不確定這是否也能解決您的布局問題,但絕對是您的代碼的問題。 如果您在此修復后仍然遇到相同的布局問題,則搜索錯誤消息可能會提供有用的結果。

嘗試改變

snapshot.data!.get('members')[index][0],

Text(
  snapshot.data!.get('members')[index],
),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM