setShorthandInset static method

void setShorthandInset(
  1. Map<String, String?> properties,
  2. String shorthandValue
)

Implementation

static void setShorthandInset(Map<String, String?> properties, String shorthandValue) {
  List<String?>? values = getEdgeValues(shorthandValue);
  if (values == null) return;

  bool isValidInsetToken(String? token) {
    if (token == null || token.isEmpty) return false;
    if (token == INHERIT || CSSLength.isInitial(token)) return true;
    return token == AUTO ||
        CSSLength.isLength(token) ||
        CSSPercentage.isPercentage(token) ||
        CSSFunction.isFunction(token);
  }

  if (!isValidInsetToken(values[0]) ||
      !isValidInsetToken(values[1]) ||
      !isValidInsetToken(values[2]) ||
      !isValidInsetToken(values[3])) {
    return;
  }

  properties[TOP] = values[0];
  properties[RIGHT] = values[1];
  properties[BOTTOM] = values[2];
  properties[LEFT] = values[3];
}