setProperty method
Modifies an existing CSS property or creates a new CSS property in the declaration block.
Implementation
void setProperty(String propertyName, String? value, {bool? isImportant, String? baseHref}) {
propertyName = propertyName.trim();
// Null or empty value means should be removed.
if (isNullOrEmptyValue(value)) {
removeProperty(propertyName, isImportant);
return;
}
String normalizedValue = _toLowerCase(propertyName, value.toString().trim());
if (!_isValidValue(propertyName, normalizedValue)) return;
if (_CSSShorthandProperty[propertyName] != null) {
return _expandShorthand(propertyName, normalizedValue, isImportant);
}
// From style sheet mark the property important as false.
if (isImportant == false) {
_sheetStyle[propertyName] = normalizedValue;
}
// If the important property is already set, we should ignore it.
if (isImportant != true && _importants[propertyName] == true) {
return;
}
if (isImportant == true) {
_importants[propertyName] = true;
}
String? prevValue = getPropertyValue(propertyName);
if (normalizedValue == prevValue) return;
_pendingProperties[propertyName] = CSSPropertyValue(normalizedValue, baseHref: baseHref);
}