SealdSsksTMRPlugin constructor

SealdSsksTMRPlugin({
  1. required String ssksURL,
  2. required String appId,
  3. int logLevel = 0,
  4. bool logNoColor = false,
  5. String instanceName = "",
})

Initialize an instance of Seald SSKS TMR plugin.

ssksURL - The URL of the SSKS Identity Key Storage to which it should connect. appId - The ID given by the Seald server to your app. This value is given on your Seald dashboard. logLevel - The minimum level of logs you want. All logs of this level or above will be displayed. -1: Trace; 0: Debug; 1: Info; 2: Warn; 3: Error; 4: Fatal; 5: Panic; 6: NoLevel; 7: Disabled. Defaults to 0. logNoColor - Whether to disable colors in the log output. true to disable colors, false to enable colors. Defaults to false. instanceName - An arbitrary name to give to this Seald instance. Can be useful for debugging when multiple instances are running in parallel, as it is added to logs. Defaults to an empty string.

Implementation

SealdSsksTMRPlugin({
  required String ssksURL,
  required String appId,
  int logLevel = 0,
  bool logNoColor = false,
  String instanceName = "",
}) {
  final Pointer<NativeSealdSsksTMRPluginInitializeOptions> initOpts =
      calloc<NativeSealdSsksTMRPluginInitializeOptions>();
  final String platform = "c-flutter-${Platform.operatingSystem}";
  initOpts.ref
    ..SsksURL = ssksURL.toNativeUtf8()
    ..AppId = appId.toNativeUtf8()
    ..LogLevel = logLevel
    ..LogNoColor = logNoColor ? 1 : 0
    ..InstanceName = instanceName.toNativeUtf8()
    ..Platform = platform.toNativeUtf8();

  final Pointer<Pointer<NativeSealdSsksTMRPlugin>> result =
      calloc<Pointer<NativeSealdSsksTMRPlugin>>();
  final Pointer<Pointer<NativeSealdError>> err =
      calloc<Pointer<NativeSealdError>>();

  final int resultCode =
      _bindings.SealdSsksTMRPlugin_Initialize(initOpts, result, err);

  calloc.free(initOpts.ref.SsksURL);
  calloc.free(initOpts.ref.AppId);
  calloc.free(initOpts.ref.InstanceName);
  calloc.free(initOpts.ref.Platform);
  calloc.free(initOpts);

  if (resultCode != 0) {
    calloc.free(result);
    throw SealdException._fromCPtr(err);
  } else {
    _ptr = _TransferablePointer<NativeSealdSsksTMRPlugin>(result.value);
    _finalizer.attach(this, _ptr.pointer() as Pointer<Void>);
    calloc.free(result);
    calloc.free(err);
  }
}