flutterdartflutter-listview

Why does my flutter ListView.Builder gives renderflex overflowed error?


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),
]
)
)

}
)
]
)
)

Solution

  • Try these two steps:

    1. Wrap the ListView.builder inside an Expanded widget.
    2. Ensure that the height of the Container widget in your code is enough to contain the reviews.name + reviews.reviewBody.