register method
Registers the provided reference
to be imported.
Implementation
@override
String? register(
TypeReference reference,
) {
if (reference.url == null || exclude.contains(reference.url)) {
return null;
}
try {
final import = imports //
.where((v) => v.url == reference.url)
.first;
return import.as;
} //
catch (_) {
// This is the first registration of this dependency.
final prefix = '_i${imports.length + 1}';
final directive = Directive.import(
reference.url!,
as: prefix,
);
imports.add(directive);
return prefix;
}
}