importIdentity method
Loads an identity export into the current SDK instance. This function can only be called if the current SDK instance does not have an account yet.
identity
- The identity export that this SDK instance should import.
Implementation
void importIdentity(Uint8List identity) {
if (_closed) {
throw SealdException(
code: "INSTANCE_CLOSED",
id: "FLUTTER_INSTANCE_CLOSED",
description: "Instance already closed.");
}
// Dart FFI forces us to copy the data from Uint8List to a newly allocated Pointer<Uint8>
final Pointer<Uint8> nativeIdentity = calloc<Uint8>(identity.length);
final pointerList = nativeIdentity.asTypedList(identity.length);
pointerList.setAll(0, identity);
final Pointer<Pointer<NativeSealdError>> err =
calloc<Pointer<NativeSealdError>>();
final int resultCode = _bindings.SealdSdk_ImportIdentity(
_ptr.pointer(), nativeIdentity, identity.length, err);
calloc.free(nativeIdentity);
if (resultCode != 0) {
throw SealdException._fromCPtr(err);
} else {
calloc.free(err);
}
}