performVerticalIntrinsicLayout method
AxisConfiguration<int>
performVerticalIntrinsicLayout(
{ - required Map<int, double> childrenHeights,
- required Map<int, double> childrenBaselines,
- bool isComputingIntrinsics = false,
})
Implementation
@override
AxisConfiguration<int> performVerticalIntrinsicLayout({
required Map<int, double> childrenHeights,
required Map<int, double> childrenBaselines,
bool isComputingIntrinsics = false,
}) {
final childHeights = List.generate(
cols * rows,
(index) => childrenBaselines[index] ?? 0.0,
growable: false,
);
final childDepth = List.generate(cols * rows, (index) {
final height = childrenBaselines[index];
return height != null ? childrenHeights[index]! - height : 0.0;
}, growable: false);
// Calculate height and depth for each row
// Minimum height and depth are 0.7 * arrayskip and 0.3 * arrayskip
final rowHeights = List.filled(rows, 0.7 * arrayskip, growable: false);
final rowDepth = List.filled(rows, 0.3 * arrayskip, growable: false);
for (var i = 0; i < rows; i++) {
for (var j = 0; j < cols; j++) {
rowHeights[i] = math.max(
rowHeights[i],
childHeights[i * cols + j],
);
rowDepth[i] = math.max(
rowDepth[i],
childDepth[i * cols + j],
);
}
}
// Layout rows
var pos = 0.0;
final rowBaselinePos = List.filled(rows, 0.0, growable: false);
final hLinePos = List.filled(rows + 1, 0.0, growable: false);
for (var i = 0; i < rows; i++) {
hLinePos[i] = pos;
pos += (hLines[i] != MatrixSeparatorStyle.none) ? ruleThickness : 0.0;
pos += rowHeights[i];
rowBaselinePos[i] = pos;
pos += rowDepth[i];
pos += i < rows - 1 ? rowSpacings[i] : 0;
}
hLinePos[rows] = pos;
pos += (hLines[rows] != MatrixSeparatorStyle.none) ? ruleThickness : 0.0;
totalHeight = pos;
// Calculate position for each children
final childPos = List.generate(rows * cols, (index) {
final row = index ~/ cols;
return rowBaselinePos[row] - childHeights[index];
}, growable: false);
if (!isComputingIntrinsics) {
this.hLinePos = hLinePos;
}
return AxisConfiguration(
size: totalHeight,
offsetTable: childPos.asMap(),
);
}