performHorizontalIntrinsicLayout method
AxisConfiguration<int>
performHorizontalIntrinsicLayout(
{ - required Map<int, double> childrenWidths,
- bool isComputingIntrinsics = false,
})
Implementation
@override
AxisConfiguration<int> performHorizontalIntrinsicLayout({
required Map<int, double> childrenWidths,
bool isComputingIntrinsics = false,
}) {
final childWidths = List.generate(
cols * rows, (index) => childrenWidths[index] ?? 0.0,
growable: false);
// Calculate width for each column
final colWidths = List.filled(cols, 0.0, growable: false);
for (var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
colWidths[i] = math.max(
colWidths[i],
childWidths[j * cols + i],
);
}
}
// Layout each column
final colPos = List.filled(cols, 0.0, growable: false);
final vLinePos = List.filled(cols + 1, 0.0, growable: false);
var pos = 0.0;
vLinePos[0] = pos;
pos += (vLines[0] != MatrixSeparatorStyle.none) ? ruleThickness : 0.0;
pos += hskipBeforeAndAfter ? arraycolsep : 0.0;
for (var i = 0; i < cols - 1; i++) {
colPos[i] = pos;
pos += colWidths[i] + arraycolsep;
vLinePos[i + 1] = pos;
pos += (vLines[i + 1] != MatrixSeparatorStyle.none) ? ruleThickness : 0.0;
pos += arraycolsep;
}
colPos[cols - 1] = pos;
pos += colWidths[cols - 1];
pos += hskipBeforeAndAfter ? arraycolsep : 0.0;
vLinePos[cols] = pos;
pos += (vLines[cols] != MatrixSeparatorStyle.none) ? ruleThickness : 0.0;
width = pos;
// Determine position of children
final childPos = List.generate(rows * cols, (index) {
final col = index % cols;
switch (columnAligns[col]) {
case MatrixColumnAlign.left:
return colPos[col];
case MatrixColumnAlign.right:
return colPos[col] + colWidths[col] - childWidths[index];
case MatrixColumnAlign.center:
default:
return colPos[col] + (colWidths[col] - childWidths[index]) / 2;
}
}, growable: false);
if (!isComputingIntrinsics) {
this.vLinePos = vLinePos;
}
return AxisConfiguration(
size: width,
offsetTable: childPos.asMap(),
);
}