'How do I make my TableRow cells the same height in flutter
I am creating a table in flutter using the Table, TableRow and TableCell widgets.
I'm using Containers as the child of TableCell with a border specified
Table(
border: TableBorder.all(width: borderWidth, color: fromHex(borderColor)),
children: List.from(content.asMap().keys.toList().map((idx) {
if (withHeadings && idx == 0) {
return createRow(
rowData: content[idx],
rowStyles: cellProperties[idx],
isHeader: true);
} else {
return createRow(
rowData: content[idx],
rowStyles: cellProperties[idx],
isHeader: false);
}
})),
)
TableRow createRow({dynamic rowData, List rowStyles, bool isHeader = false}) {
List<Widget> cells = List.from(rowData.asMap().keys.toList().map((idx) =>
createCell(
content: rowData[idx],
style: rowStyles[idx],
isHeading: isHeader)));
return TableRow(children: cells);
}
Widget createCell({String content, Map style, isHeading = false}) {
String backgroundColor = style['backgroundColor'];
String borderColor = style['borderColor'];
double borderWidth =
double.parse(style['borderWidth'].replaceAll('px', ''));
String textDirection = blockData['tunes']['alignment']['direction'];
String textAlignment = blockData['tunes']['alignment']['alignment'];
String cellContent = isHeading ? '<b>$content</b>' : content;
return TableCell(
child: Container(
decoration: BoxDecoration(
color: fromHex(backgroundColor),
border:
Border.all(color: fromHex(borderColor), width: borderWidth)),
child: Html(
data: """<div style="font-size:14px">$cellContent</div>""",
style: generateParagraphStyle(
alignment: textAlignment, textDirection: textDirection),
)),
);
}
Because the other text in the row is longer and the container has a border it cuts in the middle of the cell (when the border is taken off it would look normal)
How can I get all the cells to have the height of the largest cell in the same row so there are no divisions?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

