Api.create constructor

Api.create({
  1. String host = 'dev.xmtp.network',
  2. int port = 5556,
  3. bool isSecure = true,
  4. bool debugLogRequests = kDebugMode,
  5. String appVersion = "dev/0.0.0-development",
})

Implementation

factory Api.create({
  String host = 'dev.xmtp.network',
  int port = 5556,
  bool isSecure = true,
  bool debugLogRequests = kDebugMode,
  String appVersion = "dev/0.0.0-development",
}) {
  var channel = grpc.ClientChannel(
    host,
    port: port,
    options: grpc.ChannelOptions(
      credentials: isSecure
          ? const grpc.ChannelCredentials.secure()
          : const grpc.ChannelCredentials.insecure(),
      userAgent: clientVersion,
    ),
  );

  return Api.createAdvanced(
    channel,
    options: grpc.CallOptions(
      timeout: const Duration(minutes: 5),
      // TODO: consider supporting compression
      // compression: const grpc.GzipCodec(),
    ),
    interceptors: debugLogRequests ? [_DebugLogInterceptor()] : [],
    appVersion: appVersion,
  );
}