clearSheetStyle method

void clearSheetStyle()

Implementation

void clearSheetStyle() {
  final CSSStyleDeclaration? removedSheetStyle = _sheetStyle;
  if (removedSheetStyle == null || removedSheetStyle.isEmpty) return;
  _sheetStyle = null;

  for (final entry in removedSheetStyle) {
    style.removeProperty(entry.key, entry.value.important ? true : null);
  }

  // Re-apply inline declarations after removing sheet overrides so inline
  // styles remain effective (especially when a sheet `!important` was
  // previously winning).
  if (inlineStyle.isNotEmpty) {
    final bool enableBlink = ownerDocument.ownerView.enableBlink;
    final bool validate = !enableBlink;
    inlineStyle.forEach((propertyName, inlineEntry) {
      if (inlineEntry.value.isEmpty) return;
      style.enqueueInlineProperty(
        propertyName,
        inlineEntry.value,
        isImportant: inlineEntry.important ? true : null,
        validate: validate,
      );
    });
  }
}