본문 바로가기
Development Solutions/Flutter & Dart

[flutter] How to adjust the height of the Grid View widget(그리드 뷰 위젯 높이 조절하는 방법)

by studio ODOC 2021. 10. 31.
반응형

[flutter]

How to adjust the height of the Grid View widget

(그리드 뷰 위젯 높이 조절하는 방법)




GridView.count의 childAspectRatio를 설정하면 된다.


(Set the childAspectRatio of GridView.count.)

Widget build(BuildContext context) {
    var size = MediaQuery.of(context).size;
    final double itemHeight = (size.height - kToolbarHeight - 24) / 2;
    final double itemWidth = size.width / 2;

    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Container(
        child: new GridView.count(
          crossAxisCount: 2,
          childAspectRatio: (itemWidth / itemHeight),



https://stackoverflow.com/questions/48405123/how-to-set-custom-height-for-widget-in-gridview-in-flutter

 

How to set Custom height for Widget in GridView in Flutter?

Even after specifying the height for Container GridView, my code is producing square widgets. class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); fi...

stackoverflow.com

 

반응형