resolveTextShadow static method

List<Shadow> resolveTextShadow(
  1. String value,
  2. RenderStyle renderStyle,
  3. String propertyName
)

Implementation

static List<Shadow> resolveTextShadow(String value, RenderStyle renderStyle, String propertyName) {
  List<Shadow> textShadows = [];

  var shadows = CSSStyleProperty.getShadowValues(value);
  if (shadows != null) {
    for (var shadowDefinitions in shadows) {
      String shadowColor = shadowDefinitions[0] ?? CURRENT_COLOR;
      // Specifies the color of the shadow. If the color is absent, it defaults to currentColor.
      Color? color = CSSColor.resolveColor(shadowColor, renderStyle, propertyName);
      double offsetX = CSSLength.parseLength(shadowDefinitions[1]!, renderStyle, propertyName).computedValue;
      double offsetY = CSSLength.parseLength(shadowDefinitions[2]!, renderStyle, propertyName).computedValue;
      String? blurRadiusStr = shadowDefinitions[3];
      // Blur-radius defaults to 0 if not specified.
      double blurRadius = blurRadiusStr != null ?
        CSSLength.parseLength(blurRadiusStr, renderStyle, propertyName).computedValue : 0;
      if (color != null) {
        textShadows.add(Shadow(
          offset: Offset(offsetX, offsetY),
          blurRadius: blurRadius,
          color: color,
        ));
      }
    }
  }

  return textShadows;
}