getting " ‘hasSize’: RenderBox was not laid out:" . wraping listview builder with expanded doesn’t work. how to fix it? . Wraping the listview with a sized box works. but The Ui requirement is the card needs to expand with the number of list in the listview builder
Card(
elevation: 5,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"xyz",
),
),
Expanded(
child: ListView.builder(
itemCount: ,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () =>()
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Divider(),
Text(),
Text(
),
)
],
),
);
},
),
),
],
),
),
),
````
2
Answers
shrikWrap:true
physics: const NeverScrollableScrollPhysics()
to it and wrap your Scaffhold‘s body with SingleChildScrollView
widget.Example:
In case the number of children is not too big, replace the
ListView
by aColumn
. The layout of the column gets calculated beforehand and therefore should have a known height.If the number of children is indeed very large, then continue using the ListView, but you have to use constraints at some point, you may try to use a combination of
LayoutBuilder
andSizedBox
.https://www.youtube.com/watch?v=IYDVcriKjsw