I am trying to create a widget where I have a listview and one of its children is a gridview.but I get this error:
Another exception was thrown: RenderBox was not laid out: RenderViewport#45df5 NEEDS-LAYOUT NEEDS-PAIN
when I remove the gridview the error goes away. here is my code:
ListView(
children: <Widget>[
Stack(
overflow: Overflow.visible,
children: <Widget>[
_buildSlider(context),
_buildAppBar(context),
],
),
GridView.builder(
itemCount: state.homePageData.categories.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
itemBuilder: (BuildContext context, int index) {
return Card(
child: GridTile(
header: Text(state.homePageData.categories[index].name),
child: Image.network(baseUrl +
state.homePageData.categories[index].img.toString(),height: 50,width: 50,),
),
);
},
)
],
)