addImportsTo method

void addImportsTo(
  1. Set<FileGenerator> imports,
  2. Set<FileGenerator> enumImports
)

Adds dependencies of generate to imports.

For each .pb.dart file that the generated code needs to import, add its generator.

Implementation

void addImportsTo(
    Set<FileGenerator> imports, Set<FileGenerator> enumImports) {
  if (!_resolved) throw StateError('resolve not called');
  final typeGen = _field.baseType.generator;
  if (typeGen is EnumGenerator) {
    // Enums are always in a different file.
    enumImports.add(typeGen.fileGen!);
  } else if (typeGen != null && typeGen.fileGen != fileGen) {
    imports.add(typeGen.fileGen!);
  }
}