setAttr method
Sets an attribute on the element.
If value is null, the attribute is removed.
If the attribute is in observedAttributes, attributeChangedCallback
will be triggered by the MutationObserver.
Does nothing if not hydrated or running on server.
Example
setAttr('count', '5'); // Sets count="5"
setAttr('disabled', ''); // Sets disabled="" (boolean attribute)
setAttr('count', null); // Removes the count attribute
Implementation
void setAttr(String name, String? value) {
if (_element == null) return;
if (value == null) {
_element!.removeAttribute(name);
} else {
_element!.setAttribute(name, value);
}
}