skip to Main Content

I am trying to get all of the data info. in my firebase cloud firestore but am still struggling with the code:

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,
            );
          });
  }),

enter image description here
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.’,

2

Answers


  1. You’re adding a [0] that isn’t needed.

    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.

    Login or Signup to reply.
  2. Try changing

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

    to

    Text(
      snapshot.data!.get('members')[index],
    ),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search