modifyInitialFractionsToIncludeFirstHeader static method
List<double>
modifyInitialFractionsToIncludeFirstHeader(
- List<
double> initialFractions, - List<
PreferredSizeWidget> headers, - double totalHeight
Implementation
@visibleForTesting
static List<double> modifyInitialFractionsToIncludeFirstHeader(
List<double> initialFractions,
List<PreferredSizeWidget> headers,
double totalHeight,
) {
var totalHeaderHeight = 0.0;
for (final header in headers) {
totalHeaderHeight += header.preferredSize.height;
}
final intendedContentHeight = totalHeight - totalHeaderHeight;
final intendedChildHeights = List<double>.generate(
initialFractions.length,
(i) => intendedContentHeight * initialFractions[i],
);
final trueContentHeight =
intendedContentHeight + headers[0].preferredSize.height;
return List<double>.generate(initialFractions.length, (i) {
if (i == 0) {
return (intendedChildHeights[i] + headers[0].preferredSize.height) /
trueContentHeight;
}
return intendedChildHeights[i] / trueContentHeight;
});
}