render method
Renders the widget onto the provided buffer within the specified area.
Implementation
@override
void render(Buffer buffer, Rect area) {
int childWidth = area.width;
int childHeight = area.height;
if (child is SizedBox) {
final sb = child as SizedBox;
childWidth = sb.width ?? area.width;
childHeight = sb.height ?? area.height;
} else if (child is ConstrainedBox) {
final cb = child as ConstrainedBox;
childWidth = area.width.clamp(
cb.constraints.minWidth,
cb.constraints.maxWidth,
);
childHeight = area.height.clamp(
cb.constraints.minHeight,
cb.constraints.maxHeight,
);
}
if (widthFactor != null) {
childWidth = (childWidth * widthFactor!).round();
}
if (heightFactor != null) {
childHeight = (childHeight * heightFactor!).round();
}
childWidth = childWidth.clamp(0, area.width);
childHeight = childHeight.clamp(0, area.height);
final double remainingWidth = (area.width - childWidth).toDouble();
final int offsetX = (remainingWidth * (alignment.x + 1.0) / 2.0).round();
final double remainingHeight = (area.height - childHeight).toDouble();
final int offsetY = (remainingHeight * (alignment.y + 1.0) / 2.0).round();
final childArea = Rect(
area.x + offsetX,
area.y + offsetY,
childWidth,
childHeight,
);
final childViewport = Viewport(buffer, childArea);
child.render(childViewport, Rect(0, 0, childWidth, childHeight));
}