removeProperty method
Removes a property from the CSS declaration.
Implementation
@override
void removeProperty(String propertyName, [bool? isImportant]) {
propertyName = CSSStyleDeclaration.normalizePropertyName(propertyName);
switch (propertyName) {
case PADDING:
return CSSStyleProperty.removeShorthandPadding(this, isImportant);
case MARGIN:
return CSSStyleProperty.removeShorthandMargin(this, isImportant);
case INSET:
return CSSStyleProperty.removeShorthandInset(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 GRID_TEMPLATE:
return CSSStyleProperty.removeShorthandGridTemplate(this, isImportant);
case GRID:
return CSSStyleProperty.removeShorthandGrid(this, isImportant);
case PLACE_CONTENT:
return CSSStyleProperty.removeShorthandPlaceContent(this, isImportant);
case PLACE_ITEMS:
return CSSStyleProperty.removeShorthandPlaceItems(this, isImportant);
case PLACE_SELF:
return CSSStyleProperty.removeShorthandPlaceSelf(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 GAP:
return CSSStyleProperty.removeShorthandGap(this, isImportant);
case GRID_ROW:
return CSSStyleProperty.removeShorthandGridRow(this, isImportant);
case GRID_COLUMN:
return CSSStyleProperty.removeShorthandGridColumn(this, isImportant);
case GRID_AREA:
return CSSStyleProperty.removeShorthandGridArea(this, isImportant);
case BORDER:
case BORDER_TOP:
case BORDER_RIGHT:
case BORDER_BOTTOM:
case BORDER_LEFT:
case BORDER_INLINE_START:
case BORDER_INLINE_END:
case BORDER_BLOCK_START:
case BORDER_BLOCK_END:
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);
case ANIMATION:
return CSSStyleProperty.removeShorthandAnimation(this, isImportant);
}
String present = EMPTY_STRING;
// Fallback to default style (UA / element default).
final dynamic defaultValue = defaultStyle?[propertyName];
if (CSSStyleDeclaration.isNullOrEmptyValue(present) && !CSSStyleDeclaration.isNullOrEmptyValue(defaultValue)) {
present = defaultValue.toString();
}
// If there is still no value, fall back to the CSS initial value for
// this property. To preserve inheritance semantics, we only do this for
// non-inherited properties. For inherited ones we prefer leaving the
// value empty so [RenderStyle] can pull from the parent instead.
if (CSSStyleDeclaration.isNullOrEmptyValue(present) && cssInitialValues.containsKey(propertyName)) {
final String kebabName = _kebabize(propertyName);
final bool isInherited = isInheritedPropertyString(kebabName);
if (!isInherited) {
present = cssInitialValues[propertyName];
}
}
// Update removed value by flush pending properties.
_pendingProperties[propertyName] = CSSPropertyValue(
present,
important: false,
propertyType: PropertyType.sheet,
);
}