getAttributeOrNull<T extends Object?> method

T? getAttributeOrNull<T extends Object?>(
  1. String attributeName
)
inherited

Gets the attribute with the given name or null if it does not exist.

Note: A null value does not necessarily mean that the attribute does not exist. It could also mean that the attribute exists but has a null value. To distinguish between these two cases, use hasAttribute instead.

Implementation

T? getAttributeOrNull<T extends Object?>(String attributeName) {
  if (hasAttribute(attributeName)) {
    return getAttribute<T>(attributeName);
  }
  return null;
}