1

showing this error when I use column in StreamBuilder

error:

════════ Exception caught by rendering library ═════════════════════════════════ RenderBox was not laid out: RenderRepaintBoundary#6d45d relayoutBoundary=up2 NEEDS-PAINT 'package:flutter/src/rendering/box.dart': package:flutter/…/rendering/box.dart:1 Failed assertion: line 2001 pos 12: 'hasSize'

The relevant error-causing widget was Column

enter image description here

body: StreamBuilder(
          stream: FirebaseFirestore.instance
              .collection("posts")
              .orderBy('datePublished', descending: true)
              .snapshots(),
          builder: (context,
              AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) {
            
            //connection no problem
            return Column(
              children: [
                SizedBox(
                  height: 100.0,
                  child: ListView.builder(
                    shrinkWrap: true,
                    scrollDirection: Axis.horizontal,
                    itemCount: 5,
                    itemBuilder: (context, index) => Container(
                      padding: const EdgeInsets.all(12),
                      margin: const EdgeInsets.all(12),
                      height: 250,
                      width: 150,
                      color: Colors.pink,
                    ),
                  ),
                ),
                ListView.builder(
                  itemCount: snapshot.data!.docs.length,
                  itemBuilder: (context, index) => PostCard(
                    snap: snapshot.data!.docs[index].data(),
                  ),
                )
              ],
            );
          },
        ));

1 Answer 1

1

ListView need bounded size, when you wrap it with Expanded you set its bound, try this:

Expanded(
    child: ListView.builder(
      itemCount: snapshot.data!.docs.length,
      itemBuilder: (context, index) => PostCard(
        snap: snapshot.data!.docs[index].data(),
      ),
    ),
  ),
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.