removeProperty method

void removeProperty(
  1. String propertyName, [
  2. bool? isImportant
])

Removes a property from the CSS declaration.

Implementation

void removeProperty(String propertyName, [bool? isImportant]) {
  switch (propertyName) {
    case PADDING:
      return CSSStyleProperty.removeShorthandPadding(this, isImportant);
    case MARGIN:
      return CSSStyleProperty.removeShorthandMargin(this, isImportant);
    case BACKGROUND:
      return CSSStyleProperty.removeShorthandBackground(this, isImportant);
    case BACKGROUND_POSITION:
      return CSSStyleProperty.removeShorthandBackgroundPosition(this, isImportant);
    case BORDER_RADIUS:
      return CSSStyleProperty.removeShorthandBorderRadius(this, isImportant);
    case OVERFLOW:
      return CSSStyleProperty.removeShorthandOverflow(this, isImportant);
    case FONT:
      return CSSStyleProperty.removeShorthandFont(this, isImportant);
    case FLEX:
      return CSSStyleProperty.removeShorthandFlex(this, isImportant);
    case FLEX_FLOW:
      return CSSStyleProperty.removeShorthandFlexFlow(this, isImportant);
    case BORDER:
    case BORDER_TOP:
    case BORDER_RIGHT:
    case BORDER_BOTTOM:
    case BORDER_LEFT:
    case BORDER_COLOR:
    case BORDER_STYLE:
    case BORDER_WIDTH:
      return CSSStyleProperty.removeShorthandBorder(this, propertyName, isImportant);
    case TRANSITION:
      return CSSStyleProperty.removeShorthandTransition(this, isImportant);
    case TEXT_DECORATION:
      return CSSStyleProperty.removeShorthandTextDecoration(this, isImportant);

  }

  String present = EMPTY_STRING;
  if (isImportant == true) {
    _importants.remove(propertyName);
    // Fallback to css style.
    String? value = _sheetStyle[propertyName];
    if (!isNullOrEmptyValue(value)) {
      present = value!;
    }
  } else if (isImportant == false) {
    _sheetStyle.remove(propertyName);
  }

  // Fallback to default style.
  if (isNullOrEmptyValue(present) && defaultStyle != null && defaultStyle!.containsKey(propertyName)) {
    present = defaultStyle![propertyName];
  }

  // Update removed value by flush pending properties.
  _pendingProperties[propertyName] = present;
}