getAttribute<T> method
Retrieves a request-scoped attribute by key.
Returns the attribute value if found and assignable to T, otherwise
returns null. A stored value of a different type (e.g. written through a
legacy string key or a same-name key collision) is treated as absent
instead of throwing a runtime type error.
Implementation
T? getAttribute<T>(String key) {
final value = _attributes[key];
if (value is T) return value;
return null;
}