Методы установки высоты строки в таблице Flutter | Параметры высоты строк таблицы Flutter

  1. Установить фиксированную высоту: вы можете указать фиксированную высоту для каждой строки с помощью виджета TableRowHeight. Например:

    Table(
    children: [
    TableRow(
      children: [
        Container(
          height: 50, // Set the desired height
          child: YourWidget(),
        ),
        // Other cells
      ],
    ),
    // Other rows
    ],
    )
  2. Использовать внутреннюю высоту. По умолчанию TableRow попытается изменить размер своих ячеек на основе их внутренней высоты. Вы можете обернуть свой контент в SizedBox или контейнер с ограничениями для управления высотой. Например:

    Table(
    children: [
    TableRow(
      children: [
        SizedBox(
          height: 100, // Set the desired height
          child: YourWidget(),
        ),
        // Other cells
      ],
    ),
    // Other rows
    ],
    )
  3. Настройте отрисовку ячеек. Если вам нужен более детальный контроль над высотой строки, вы можете использовать TableCell и предоставить собственный TableCellRenderer. В средстве визуализации вы можете указать высоту для каждой строки. Вот пример:

    class CustomTableCellRenderer extends TableCellRenderer {
    @override
    void render(CellRenderBox cell, double x, double y, double width, double height) {
    // Adjust the height as needed
    final double desiredHeight = 80;
    final double cellY = y + (height - desiredHeight) / 2;
    cell.child?.layout(BoxConstraints.tightFor(width: width, height: desiredHeight));
    cell.child?.paint(PaintingContext(null, null), Offset(x, cellY));
    }
    }
    // Usage
    Table(
    children: [
    TableRow(
      children: [
        TableCell(
          child: YourWidget(),
          renderer: CustomTableCellRenderer(),
        ),
        // Other cells
      ],
    ),
    // Other rows
    ],
    )