颤振行宽

问题描述 投票:0回答:1

flutter中可以定义行的大小吗? 这是我的代码, 桌子( 边框:TableBorder.all(颜色:Colors.white30), 默认垂直对齐: TableCellVerticalAlignment.middle, 孩子们: [ 表行( 装饰:BoxDecoration( 颜色: Colors.blueGrey, borderRadius: BorderRadius.only( 左上:Radius.circular(12), 右上:Radius.circular(12), ), ), 孩子们: [ // 标头列 for (var 标头在 [ “我生产”, “ID 功能”, “鳕鱼参考”, “量化”, “Hora Incial”, 《霍拉决赛》, “观察” ]) 表格单元格( 垂直对齐: TableCellVerticalAlignment.middle, 孩子:填充( 填充:const EdgeInsets.all(8.0), 孩子:文本( 标头, 样式:文本样式( 颜色: 颜色.白色, ), 文本对齐:文本对齐.center, ), ), ), ], ),

我已经查看是否存在某种方法,但我还没有找到任何东西

flutter
1个回答
0
投票

实现此目的的一种方法是将每个

TableCell
的内容包装在
Container
中并设置
Container
的高度。

Table(
    border: TableBorder.all(color: Colors.white30),
            defaultVerticalAlignment: TableCellVerticalAlignment.middle,
            children: [
              TableRow(
                decoration: BoxDecoration(
                  color: Colors.blueGrey,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(12),
                    topRight: Radius.circular(12),
                  ),
                ),
                children: [
                  for (var header in [
                    "Id produção",
                    "Id funcionário",
                    "Cod Referencia",
                    "Quantidade",
                    "Hora Incial",
                    "Hora Final",
                    "Obs"
                  ])
                    TableCell(
                      verticalAlignment: TableCellVerticalAlignment.middle,
                      child: Container(
                        height: 50, // Set the height for the header row
                        padding: const EdgeInsets.all(8.0),
                        child: Center(
                          child: Text(
                            header,
                            style: TextStyle(
                              color: Colors.white,
                            ),
                            textAlign: TextAlign.center,
                          ),
                        ),
                      ),
                    ),
                ],
              ),
              // Add more rows as needed
              TableRow(
                children: [
                  for (var cell in [
                    "1",
                    "123",
                    "ABC123",
                    "10",
                    "08:00",
                    "16:00",
                    "No issues"
                  ])
                    TableCell(
                      verticalAlignment: TableCellVerticalAlignment.middle,
                      child: Container(
                        height: 40, // Set the height for other rows
                        padding: const EdgeInsets.all(8.0),
                        child: Center(
                          child: Text(
                            cell,
                            textAlign: TextAlign.center,
                          ),
                        ),
                      ),
                    ),
                ],
              ),
            ],
          ),
        ),
© www.soinside.com 2019 - 2024. All rights reserved.