firstMetadataOfType<T> function
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?;
// ignore: avoid_catching_errors
} on StateError catch (_) {
return null;
}
}