Reputation: 61
I am trying to change my ListView to be Shown horizontally instead of veritcally by default. However, when I have done this, I face the following an error. The error occurs at both the Widgets returned by the _buildListItem function and disappears when the scrolldirection is changed from vertical back to horizontal.
RenderBox was not laid out: RenderPointerListener#98473 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
The code of the ListView Builder is
Widget _buildListItem (BuildContext context,DocumentSnapshot doc,int index)
{
if(index ==0)
{
return ListTile(title:Container( height:200,width: 100,child: Card(shape: new RoundedRectangleBorder(),child:Column(children:<Widget>[new Flexible(child:Text(widget.prayerName,style: TextStyle(fontSize: 32,fontWeight: FontWeight.bold))),Text(widget.blurb,style: TextStyle(fontSize: 28))]))));
}
else {
return RaisedButton(child: Text("a"),);
}
}
Here is the body of my build widget where my list view is declared
body: StreamBuilder(
stream: Firestore.instance.collection('quranKhwani').document(widget.docID).collection("juz").orderBy("juzNumber").snapshots(),
builder: (context,snapshot)
{
if(!snapshot.hasData)return const Text("Loading..");
return ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder: (context,index)=>
_buildListItem(context,snapshot.data.documents[index],index),
itemCount: snapshot.data.documents.length,
);
}
)
));
Upvotes: 0
Views: 347
Reputation: 3460
Container(
height: _height //add height
child: StreamBuilder(
builder: (context, snapshot) {
return ListView.builder(
itemBuilder: (context, index) {},
scrollDirection: Axis.horizontal,
);
},
),
)
Upvotes: 1
Reputation: 4095
You have to give height to the StreamBuilder
like:
body: Container(
height: 300, // Height you want
child:
StreamBuilder(
stream: Firestore.instance.collection('quranKhwani').document(widget.docID).collection("juz").orderBy("juzNumber").snapshots(),
builder: (context,snapshot)
{
if(!snapshot.hasData)return const Text("Loading..");
return ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder: (context,index)=>
_buildListItem(context,snapshot.data.documents[index],index),
itemCount: snapshot.data.documents.length,
);
}
),
),
),
Upvotes: 0