parseBorderRadius static method

CSSBorderRadius? parseBorderRadius(
  1. String radius,
  2. RenderStyle renderStyle,
  3. String propertyName
)

Implementation

static CSSBorderRadius? parseBorderRadius(String radius, RenderStyle renderStyle, String propertyName) {
  if (radius.isNotEmpty) {
    // border-top-left-radius: horizontal vertical
    List<String> values = radius.split(_splitRegExp);
    if (values.length == 1 || values.length == 2) {
      String horizontalRadius = values[0];
      // The first value is the horizontal radius, the second the vertical radius.
      // If the second value is omitted it is copied from the first.
      // https://www.w3.org/TR/css-backgrounds-3/#border-radius
      String verticalRadius = values.length == 1 ? values[0] : values[1];
      CSSLengthValue x = CSSLength.parseLength(horizontalRadius, renderStyle, propertyName, Axis.horizontal);
      CSSLengthValue y = CSSLength.parseLength(verticalRadius, renderStyle, propertyName, Axis.vertical);
      return CSSBorderRadius(x, y);
    }
  }
  return null;
}