attributeAsString method

String attributeAsString(
  1. String attrName
)

Retrieve the string associated with a specific attribute name.

If the attribute's first parameter is not a string, then return an empty string.

Implementation

String attributeAsString(String attrName) {
  final attr = findAttribute(attrName);
  if (attr == null ||
      attr.parameters.isEmpty ||
      attr.parameters.first.type.baseType != BaseType.String) {
    return '';
  }

  return attr.parameters.first.value as String;
}