attribute<T> method

Future<T> attribute<T>(
  1. String attributeName, {
  2. Converter<T>? convert,
})

Extracts an attribute by name. Throws MissingAttribute if not found.

T The type to return. Specify as e.g. attribute<double>(...)) Defaults to String. attributeName the name of the attribute to find. Accepts fully qualified or unqualified names. converter A function of the form T Function(String) that parses the string to an object. Not needed for any of the primitive types or Uri. (See autoConverter)

Implementation

Future<T> attribute<T>(String attributeName, {Converter<T>? convert}) async {
  final probe = await optionalAttribute<T>(attributeName, convert: convert);
  if (probe == null) {
    throw MissingAttribute(name, attributeName);
  }
  return probe;
}