autoScaleHeight static method

double autoScaleHeight(
  1. Node canvas,
  2. double width
)

The height an autoScale canvas takes when scaled to width: its design height times the scale, after its max width cap.

Implementation

static double autoScaleHeight(Node canvas, double width) {
  final design = designSize(canvas);
  if (design.width <= 0 || !width.isFinite) return design.height;
  final maxWidth = canvas.layout.constraints.maxWidth;
  final scaled = maxWidth == null ? width : math.min(width, maxWidth);
  return design.height * scaled / design.width;
}