processInjectableFromVariable method
Implementation
({Object? dependency, String? tag}) processInjectableFromVariable(
VariableMirror variableMirror,
) {
// Try to get the GlobalFilter annotation on the method
Injectable? injectable = variableMirror.metadata
.firstWhereOrNull(
(metadata) => metadata.reflectee is Injectable,
)
?.reflectee;
// If the annotation exists, process it
if (injectable != null) {
Object? value;
// Verifica si el owner es un ClassMirror o un LibraryMirror
var owner = variableMirror.owner;
if (owner is ClassMirror) {
// Accede al campo usando el nombre simple de la variable
var fieldMirror = owner.getField(variableMirror.simpleName);
value = fieldMirror.reflectee;
} else if (owner is LibraryMirror) {
// Para variables top-level
value = owner.getField(variableMirror.simpleName).reflectee;
}
return (dependency: value, tag: injectable.tag);
}
return (dependency: null, tag: null);
}