I have a problem with gridview and column. In this case, i want put an image in upper of gridview. Please give me a solution..
return new Container( child: new Column( children: <Widget>[ new Container( child: new Image.asset( "assets/promo.png", fit: BoxFit.cover, ), ), new Container( child: new GridView.count( crossAxisCount: 2, childAspectRatio: (itemWidth / itemHeight), controller: new ScrollController(keepScrollOffset: false), shrinkWrap: true, scrollDirection: Axis.vertical, children: new List<Widget>.generate(16, (index) { return new GridTile( header: new Container( padding: const EdgeInsets.all(10.0), alignment: Alignment.centerRight, child: new Icon( Icons.shopping_cart, size: 20.0, color: Colors.red, ), ), child: new MyList( nomor: '$index', )); }), ), ), ], ), );
and this is the result: Flutter Gridview in Column
You just need to put your GridView Widget into the Expanded Widget, for example: body: new Column( children: <Widget>[ new Expanded( child: GridView. count( // Create a grid with 2 columns. If you change the scrollDirection to // horizontal, this would produce 2 rows.
gridDelegate property Null safetyA delegate that controls the layout of the children within the GridView. The GridView, GridView. builder, and GridView. custom constructors let you specify this delegate explicitly. The other constructors create a gridDelegate implicitly.
You just need to put your grid view into Expanded
widget, for example:
body: new Column( children: <Widget>[ new Expanded( child: GridView.count( // Create a grid with 2 columns. If you change the scrollDirection to // horizontal, this would produce 2 rows. crossAxisCount: 2, // Generate 100 Widgets that display their index in the List children: List.generate(10, (index) { return _buildCard(index); }), ), ), new Text("text") ], ),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With