getWidthByIntrinsicRatio method

  1. @override
double getWidthByIntrinsicRatio()
override

Implementation

@override
double getWidthByIntrinsicRatio() {
  double contentBoxWidth;

  double borderBoxHeight = height.isAuto
    ? wrapPaddingBorderHeight(intrinsicHeight) : height.computedValue;
  if (!minHeight.isAuto && borderBoxHeight < minHeight.computedValue) {
    borderBoxHeight = minHeight.computedValue;
  }
  if (!maxHeight.isNone && borderBoxHeight > maxHeight.computedValue) {
    borderBoxHeight = maxHeight.computedValue;
  }

  if (borderBoxHeight != 0 && intrinsicHeight != 0) {
    double contentBoxHeight = deflatePaddingBorderHeight(borderBoxHeight);
    contentBoxWidth = contentBoxHeight * intrinsicWidth / intrinsicHeight;
  } else {
    contentBoxWidth = intrinsicWidth;
    if (minWidth.isNotAuto && contentBoxWidth < minWidth.computedValue) {
      contentBoxWidth = minWidth.computedValue;
    }
    if (maxWidth.isNotNone && contentBoxWidth > maxWidth.computedValue) {
      contentBoxWidth = maxWidth.computedValue;
    }
  }

  double borderBoxWidth = wrapPaddingBorderWidth(contentBoxWidth);

  return borderBoxWidth;
}