getHeightByAspectRatio method

  1. @override
double getHeightByAspectRatio()
override

Implementation

@override
double getHeightByAspectRatio() {
  double contentBoxHeight;
  double borderBoxWidth = width.isAuto ? wrapPaddingBorderWidth(intrinsicWidth) : width.computedValue;
  if (minWidth.isNotAuto && borderBoxWidth < minWidth.computedValue) {
    borderBoxWidth = minWidth.computedValue;
  }
  if (maxWidth.isNotNone && borderBoxWidth > maxWidth.computedValue) {
    borderBoxWidth = maxWidth.computedValue;
  }

  if (borderBoxWidth != 0 && intrinsicWidth != 0) {
    double contentBoxWidth = deflatePaddingBorderWidth(borderBoxWidth);
    contentBoxHeight = contentBoxWidth * intrinsicHeight / intrinsicWidth;
  } else {
    contentBoxHeight = intrinsicHeight;
    if (!minHeight.isAuto && contentBoxHeight < minHeight.computedValue) {
      contentBoxHeight = minHeight.computedValue;
    }
    if (!maxHeight.isNone && contentBoxHeight > maxHeight.computedValue) {
      contentBoxHeight = maxHeight.computedValue;
    }
  }

  double borderBoxHeight = wrapPaddingBorderHeight(contentBoxHeight);

  return borderBoxHeight;
}