allocate method Null safety

  1. @override
String allocate(
  1. Reference reference
)

Returns a reference string given a reference object.

For example, a no-op implementation:

allocate(const Reference('List', 'dart:core')); // Returns 'List'.

Where-as an implementation that prefixes imports might output:

allocate(const Reference('Foo', 'package:foo')); // Returns '_i1.Foo'.

Implementation

@override
String allocate(Reference reference) {
  final url = reference.url;
  if (url != null && !_doNotPrefix.contains(url)) {
    _imports.add(url);
  }
  return reference.symbol!;
}