askarSessionStart function

Future<AskarResult<SessionHandle>> askarSessionStart(
  1. StoreHandle handle, {
  2. required bool asTransaction,
  3. String? profile,
})

Implementation

Future<AskarResult<SessionHandle>> askarSessionStart(
  StoreHandle handle, {
  required bool asTransaction,
  String? profile,
}) async {
  Pointer<Utf8> profilePointer = nullptr;

  try {
    profilePointer = (profile ?? "").toNativeUtf8();

    final callback = newCallbackWithHandle();

    final initialResult = nativeAskarSessionStart(
      handle.toInt(),
      profilePointer,
      boolToInt(asTransaction),
      callback.nativeCallable.nativeFunction,
      callback.id,
    );

    final completedResult = await callback.handleResult(initialResult);

    return AskarResult(completedResult.errorCode, SessionHandle(completedResult.value));
  } finally {
    freePointer(profilePointer);
  }
}