clampContentWidth static method
Clamps a measured contentWidth to a sane ceiling of 3× the viewport.
contentWidth is already expressed in the same (scaled) pixel space as
viewportWidth, so the ceiling must NOT be re-multiplied by any scale
factor — doing so scales the bound a second time.
Implementation
static double clampContentWidth({
required double contentWidth,
required double viewportWidth,
}) {
final maxAllowed = viewportWidth * 3;
return contentWidth.clamp(0.0, maxAllowed);
}