setRelativeValues method

void setRelativeValues(
  1. double remValue,
  2. double emValue
)

Sets any dimensions set to rem or em to the computed size

Implementation

void setRelativeValues(double remValue, double emValue) {
  if (width?.unit == Unit.rem) {
    width = Width(width!.value * remValue);
  } else if (width?.unit == Unit.em) {
    width = Width(width!.value * emValue);
  }

  if (height?.unit == Unit.rem) {
    height = Height(height!.value * remValue);
  } else if (height?.unit == Unit.em) {
    height = Height(height!.value * emValue);
  }

  if (fontSize?.unit == Unit.rem) {
    fontSize = FontSize(fontSize!.value * remValue);
  } else if (fontSize?.unit == Unit.em) {
    fontSize = FontSize(fontSize!.value * emValue);
  }

  Margin? marginLeft;
  Margin? marginTop;
  Margin? marginRight;
  Margin? marginBottom;

  if (margin?.left?.unit == Unit.rem) {
    marginLeft = Margin(margin!.left!.value * remValue);
  } else if (margin?.left?.unit == Unit.em) {
    marginLeft = Margin(margin!.left!.value * emValue);
  }

  if (margin?.top?.unit == Unit.rem) {
    marginTop = Margin(margin!.top!.value * remValue);
  } else if (margin?.top?.unit == Unit.em) {
    marginTop = Margin(margin!.top!.value * emValue);
  }

  if (margin?.right?.unit == Unit.rem) {
    marginRight = Margin(margin!.right!.value * remValue);
  } else if (margin?.right?.unit == Unit.em) {
    marginRight = Margin(margin!.right!.value * emValue);
  }

  if (margin?.bottom?.unit == Unit.rem) {
    marginBottom = Margin(margin!.bottom!.value * remValue);
  } else if (margin?.bottom?.unit == Unit.em) {
    marginBottom = Margin(margin!.bottom!.value * emValue);
  }

  margin = margin?.copyWith(
    left: marginLeft,
    top: marginTop,
    right: marginRight,
    bottom: marginBottom,
  );
}