writeFileImports method

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

Writes specified imports to indent.

Implementation

@override
void writeFileImports(
  JavaOptions generatorOptions,
  Root root,
  Indent indent, {
  required String dartPackageName,
}) {
  if (generatorOptions.package != null) {
    indent.writeln('package ${generatorOptions.package};');
    indent.newln();
  }
  if (root.classes.isNotEmpty) {
    indent.writeln('import static java.lang.annotation.ElementType.METHOD;');
    indent
        .writeln('import static java.lang.annotation.RetentionPolicy.CLASS;');
    indent.newln();
  }
  indent.writeln('import android.util.Log;');
  indent.writeln('import androidx.annotation.NonNull;');
  indent.writeln('import androidx.annotation.Nullable;');
  indent.writeln('import io.flutter.plugin.common.BasicMessageChannel;');
  indent.writeln('import io.flutter.plugin.common.BinaryMessenger;');
  indent.writeln('import io.flutter.plugin.common.MessageCodec;');
  indent.writeln('import io.flutter.plugin.common.StandardMessageCodec;');
  indent.writeln('import java.io.ByteArrayOutputStream;');
  if (root.classes.isNotEmpty) {
    indent.writeln('import java.lang.annotation.Retention;');
    indent.writeln('import java.lang.annotation.Target;');
  }
  indent.writeln('import java.nio.ByteBuffer;');
  indent.writeln('import java.util.ArrayList;');
  indent.writeln('import java.util.Arrays;');
  indent.writeln('import java.util.Collections;');
  indent.writeln('import java.util.HashMap;');
  indent.writeln('import java.util.List;');
  indent.writeln('import java.util.Map;');
  indent.newln();
}