This is my code:
@override
Widget build(BuildContext context) {
return new Material(
color: Colors.deepPurpleAccent,
child: new Column(
This situation typically happens when a scrollable widget is nested inside another scrollable widget.
In my case i use GridView inside of Column and that error throws.
GridView widget has shrinkWrap
property/named parameter, to set it true
my problem is fixed.
GridView.count(
shrinkWrap: true,
// rest of code
)
Don't use Column
for single child alignment. Use Align
instead.
new Align(
alignment: Alignment.topCenter,
child: new GridView(),
)
put grid view inside Flexible or Expanded widget
return new Material(
color: Colors.deepPurpleAccent,
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children:<Widget>[
Flexible(
child: GridView.count(crossAxisCount: _column,children: new List.generate(_row*_column, (index) {
return new Center(
child: new CellWidget(),
);
}),))]
)
);
Although shrinkWrap
do the thing, but you can't scroll in ListView
.
If you want scrolling functionality, you can add physics
property:
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: ScrollPhysics(),
...