ProtoBuilder constructor

ProtoBuilder(
  1. BuilderOptions options
)

Implementation

ProtoBuilder(BuilderOptions options) {
  if (options.config.isEmpty) {
    return;
  }

  protoDir = options.config["proto_dir"] as String?;

  protocVersion = options.config["protoc_version"] as String? ?? "3.19.4";

  final dartMap = options.config["dart"] as Map?;
  if (dartMap != null) {
    dartEnable = dartMap["enable"] ?? false;
    protocGenDartVersion = dartMap["protoc_gen_dart_version"] ?? "20.0.0";
    dartOutputDir = dartMap["output_dir"] as String? ?? "lib/proto_gen/";
    if (!dartOutputDir.endsWith("/")) {
      dartOutputDir += "/";
    }
  } else {
    dartEnable = false;
    protocGenDartVersion = "";
    dartOutputDir = "";
  }

  final javaMap = options.config["java"] as Map?;
  if (javaMap != null) {
    javaEnable = javaMap["enable"] ?? false;
    protocGenGrpcJavaVersion = javaMap["protoc-gen-grpc-java"] ?? "1.44.0";
    javaOutputDir =
        javaMap["output_dir"] as String? ?? "android/app/src/main/proto_gen/";
    if (!javaOutputDir.endsWith("/")) {
      javaOutputDir += "/";
    }
  } else {
    javaEnable = false;
    protocGenGrpcJavaVersion = "";
    javaOutputDir = "";
  }

  final ocMap = options.config["oc"] as Map?;
  if (ocMap != null) {
    ocEnable = ocMap["enable"] ?? false;
    ocOutputDir = ocMap["output_dir"] as String? ?? "ios/Classes/Protos/";
    if (!ocOutputDir.endsWith("/")) {
      ocOutputDir += "/";
    }
  } else {
    ocEnable = false;
    ocOutputDir = "";
  }

  downloadDepsFuture = downloadDeps();
}