writeFileImports method

  1. @override
void writeFileImports(
  1. SwiftOptions generatorOptions,
  2. Root root,
  3. Indent indent, {
  4. required String dartPackageName,
})
override

Writes specified imports to indent.

Implementation

@override
void writeFileImports(
  SwiftOptions generatorOptions,
  Root root,
  Indent indent, {
  required String dartPackageName,
}) {
  indent.writeln('import Foundation');

  final Iterable<String> proxyApiImports = root.apis
      .whereType<AstProxyApi>()
      .map((AstProxyApi proxyApi) => proxyApi.swiftOptions?.import)
      .nonNulls
      .toSet();
  for (final String import in proxyApiImports) {
    indent.writeln('import $import');
  }
  indent.newln();

  indent.format('''
#if os(iOS)
import Flutter
#elseif os(macOS)
import FlutterMacOS
#else
#error("Unsupported platform.")
#endif''');
}