firstMetadataOfType<T> function
Null safety
- DeclarationMirror dm,
- {TypeMirror? dynamicType}
Implementation
T? firstMetadataOfType<T>(DeclarationMirror dm, {TypeMirror? dynamicType}) {
final tMirror = dynamicType ?? reflectType(T);
try {
return dm.metadata
.firstWhere((im) => im.type.isSubtypeOf(tMirror))
.reflectee as T?;
} on StateError catch (_) {
return null;
}
}