Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The relevant error-causing widget was Column | flutter

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’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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(),
      ),
    ),
  ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading