[英]how to get snapshot all in an array flutter firebase cloud
I am trying to get all of the data info.我正在尝试获取所有数据信息。 in my firebase cloud firestore but am still struggling with the code:
在我的 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,
);
});
}),
I want to snapshot all of this and display it in my app
我想拍摄所有这些并将其显示在我的应用程序中
I don't think I did it right cuz this is the error that I get我认为我做的不对,因为这是我得到的错误
ErrorDescription( 'Viewports expand in the scrolling direction to fill their container. ' 'In this case, a vertical viewport was given an unlimited amount of ' 'vertical space in which to expand. This situation typically happens ' 'when a scrollable widget is nested inside another scrollable widget.',
ErrorDescription('视口在滚动方向上展开以填充其容器。''在这种情况下,垂直视口被赋予了无限量的''垂直空间来展开。这种情况通常发生在''嵌套可滚动小部件时在另一个可滚动的小部件内。',
You're adding a [0]
that isn't needed.您正在添加一个不需要的
[0]
。
Change:改变:
snapshot.data!.get('members')[index][0],
To:至:
snapshot.data!.get('members')[index],
Note that I'm not sure if that'll also fix your layout issue, but is definitely a problem with your code.请注意,我不确定这是否也能解决您的布局问题,但绝对是您的代码的问题。 If you still get the same layout problem after this fix, a search for the error message may provide useful results.
如果您在此修复后仍然遇到相同的布局问题,则搜索错误消息可能会提供有用的结果。
Try changing尝试改变
snapshot.data!.get('members')[index][0],
to至
Text(
snapshot.data!.get('members')[index],
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.