Gridview 如何设置颤振表格单元格的背景颜色?

Gridview 如何设置颤振表格单元格的背景颜色?,gridview,flutter,Gridview,Flutter,下面的代码生成一个包含3行3列的表。在第二排中,第一个和第三个单元格的颜色没有显示出来-我猜所包含的容器大小不合适,因此不可见,导致中央红细胞两侧都有一个白色单元格。如何强制侧单元格的颜色?还有没有一种方法可以强迫桌子完全呈正方形,因为我不知道屏幕的大小,或者可能不知道图标的大小?我基本上希望中心单元格包含我的数据,其他单元格充当薄边框,可以在运行时单独着色 附加了一张我的应用程序的图片,在Gridview.count()中显示了一组这些表。请注意网格每行下方的空白。我怎样才能摆脱那片空白?

下面的代码生成一个包含3行3列的表。在第二排中,第一个和第三个单元格的颜色没有显示出来-我猜所包含的容器大小不合适,因此不可见,导致中央红细胞两侧都有一个白色单元格。如何强制侧单元格的颜色?还有没有一种方法可以强迫桌子完全呈正方形,因为我不知道屏幕的大小,或者可能不知道图标的大小?我基本上希望中心单元格包含我的数据,其他单元格充当薄边框,可以在运行时单独着色

附加了一张我的应用程序的图片,在
Gridview.count()
中显示了一组这些表。请注意网格每行下方的空白。我怎样才能摆脱那片空白?


谢谢

我通过将一些表中的内部表包装到另一个表中的一些表行(在一个居中的方形大小框中)而不是GridView,并借助一些媒体查询严格调整内部表中的单元格和列的大小来解决问题。新代码如下。关于表中大小灵活的小部件,仍然存在一些问题,这是一个棘手的问题,我需要稍后了解,但也许通过这种方法,我可以在本项目中避免大部分问题。我还必须更正内部表的
列宽
参数,这些参数是从0而不是1索引的

return Table(columnWidths: {
      0: FixedColumnWidth(wallThickness),
      1: FixedColumnWidth(roomLength),
      2: FixedColumnWidth(wallThickness)
    }, children: [
      TableRow(children: [
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              height: wallThickness,
              width: wallThickness,
            ),
          ),
        ),
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              height: wallThickness,
              width: double.infinity,
            ),
          ),
        ),
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              height: wallThickness,
              width: wallThickness,
            ),
          ),
        ),
      ]),
      TableRow(
        children: [
          TableCell(
            child: Container(
              color: wallColor,
              child: SizedBox(
                height: roomLength,
                width: wallThickness,
              ),
            ),
          ),
          TableCell(
            child: GestureDetector(
              onTap: () => print('$name was tappped'),
              child: Container(
                color: floorColor,
                alignment: Alignment.center,
                child: SizedBox(
                  width: roomLength,
                  height: roomLength,

                ),
              ),
            ),
          ),
          TableCell(
            child: Container(
              color: wallColor,
              child: SizedBox(
                width: wallThickness,
                height: roomLength,
              ),
            ),
          ),
        ],
      ),
      TableRow(children: [
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              width: wallThickness,
              height: wallThickness,
            ),
          ),
        ),
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              width: roomLength,
              height: wallThickness,
            ),
          ),
        ),
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              width: wallThickness,
              height: wallThickness,
            ),
          ),
        ),
      ]),
    ]);

PS:我最终停止了在这个应用程序中使用表格,而是使用了基本的行和列。

我知道这已经晚了,但是有人从这个应用程序中得到了帮助:-decoration:BoxDecoration(color:rawColor,)
return Table(columnWidths: {
      0: FixedColumnWidth(wallThickness),
      1: FixedColumnWidth(roomLength),
      2: FixedColumnWidth(wallThickness)
    }, children: [
      TableRow(children: [
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              height: wallThickness,
              width: wallThickness,
            ),
          ),
        ),
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              height: wallThickness,
              width: double.infinity,
            ),
          ),
        ),
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              height: wallThickness,
              width: wallThickness,
            ),
          ),
        ),
      ]),
      TableRow(
        children: [
          TableCell(
            child: Container(
              color: wallColor,
              child: SizedBox(
                height: roomLength,
                width: wallThickness,
              ),
            ),
          ),
          TableCell(
            child: GestureDetector(
              onTap: () => print('$name was tappped'),
              child: Container(
                color: floorColor,
                alignment: Alignment.center,
                child: SizedBox(
                  width: roomLength,
                  height: roomLength,

                ),
              ),
            ),
          ),
          TableCell(
            child: Container(
              color: wallColor,
              child: SizedBox(
                width: wallThickness,
                height: roomLength,
              ),
            ),
          ),
        ],
      ),
      TableRow(children: [
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              width: wallThickness,
              height: wallThickness,
            ),
          ),
        ),
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              width: roomLength,
              height: wallThickness,
            ),
          ),
        ),
        TableCell(
          child: Container(
            color: wallColor,
            child: SizedBox(
              width: wallThickness,
              height: wallThickness,
            ),
          ),
        ),
      ]),
    ]);