I am trying to implement a listview builder in my flutter app to generate a scrollable list of reviews, but for some reason its giving me a renderflex overflow error. This doesn’t make any sense because a list view is designed to overflow the screen thats what the whole point of it is.
this is the gist of the code I currently have thats giving me the error.
return Scaffold(
appBar: HoomeAppBar(context),
body: Column(
children: [
Text('home'),
ListView.builder(
itemCount: 2,
shrinkWrap: true,
itemBuilder: (context, index) {
return Container(
width: 200,
height: 300,
child: Column(
children: [
Text(reviews[index].name),
Text(reviews[index].reviewBody),
]
)
)
}
)
]
)
)
3
Answers
Try these two steps:
Wrap your
ListView
insideExpanded
ListView.builder
inside anExpanded
widget.width
&height
and add column propertymainAxisSize: MainAxisSize.min
so name & reviews text display with dynamic content.