简体   繁体   中英

How to create divisions in gridview.count flutter

So i have a 9x9 grid that i want to seperate into 3x3 grids, in the backend it should remain a 9x9 grid but in the UI it should look as if it is seperated into 3x3 grids. It should look like this, ignore the colors. The margin between the 3x3 grids is what i am looking for

它看起来有点像这样

We can use Container border,

  body: GridView.count(
        crossAxisCount: 3,
        children: [
          ...List.generate(
            9,
            (index) => Container(
              decoration: BoxDecoration(
                border: Border.all(
                  width: 3,
                  color: Colors.blue,
                ),
              ),
              alignment: Alignment.center,
              child: GridView.count(
                physics: NeverScrollableScrollPhysics(),
                crossAxisCount: 3,
                children: [
                  ...List.generate(
                    9,
                    (index) => Container(
                      decoration: BoxDecoration(
                        border: Border.all(
                          width: 1,
                          color: Colors.grey,
                        ),
                      ),
                      alignment: Alignment.center,
                      child: GridView.count(
                        crossAxisCount: 3,
                      ),
                    ),
                  )
                ],
              ),
            ),
          )
        ],
      ),
   

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM