buildWidget method
Compose Flutter widget with child widgets already built
Subclasses should override this method. This method provides a general description of the layout of this math node. The child nodes are built in prior. This method is only responsible for the placement of those child widgets accroding to the layout & other interactions.
Please ensure children works in the same order as updateChildren, computeChildOptions, and buildWidget.
Implementation
@override
BuildResult buildWidget(
MathOptions options, List<BuildResult?> childBuildResults) {
if (alignerOrSpacer == true) {
return BuildResult(
options: options,
widget: Container(height: 0.0),
);
}
final height = this.height.toLpUnder(options);
final depth = this.depth.toLpUnder(options);
final width = this.width.toLpUnder(options);
final shift = this.shift.toLpUnder(options);
final topMost = math.max(height, -depth) + shift;
final bottomMost = math.min(height, -depth) + shift;
return BuildResult(
options: options,
widget: ResetBaseline(
height: topMost,
child: Container(
color: fill ? options.color : null,
height: topMost - bottomMost,
width: math.max(0.0, width),
),
),
);
}