I am using a scrollable column
and ListView.builder
inside the column
. I have checked another answers in stackoverflow and wrapped the ListView.builder
inside Expanded
widget but still problem continue
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
List<String> items = [
'item1',
'item1',
'item1',
'item1',
'item1',
'item1',
'item1',
];
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: SingleChildScrollView(
child: Column(
children: [
Text('Testing1'),
SizedBox(height: 150),
Text('Testing2'),
SizedBox(height: 150),
Text('Testing3'),
SizedBox(height: 150),
Text('Testing4'),
SizedBox(height: 150),
Text('Testing5'),
SizedBox(height: 150),
Text('Testing6'),
SizedBox(height: 150),
Text('Testing7'),
SizedBox(height: 150),
if (items.isNotEmpty)
Expanded(
child: ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(items[index]),
);
},
),
)
],
),
),
);
}
CodePudding user response:
Try below code:
SingleChildScrollView(
child: Column(
children: [
Text('Testing1'),
SizedBox(height: 150),
Text('Testing2'),
SizedBox(height: 150),
Text('Testing3'),
SizedBox(height: 150),
Text('Testing4'),
SizedBox(height: 150),
Text('Testing5'),
SizedBox(height: 150),
Text('Testing6'),
SizedBox(height: 150),
Text('Testing7'),
SizedBox(height: 150),
if (items.isNotEmpty)
ListView.builder(
shrinkWrap: true,
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(items[index]),
);
},
),
],
),
),
CodePudding user response:
Try shrinkWrap:true
inside the ListView.builder