Admin constructor

Admin(
  1. Store store, {
  2. String bindUri = 'http://127.0.0.1:8090',
})

Creates an ObjectBox Admin associated with the given store and options.

Implementation

Admin(Store store, {String bindUri = 'http://127.0.0.1:8090'}) {
  if (!isAvailable()) {
    throw UnsupportedError(
        'Admin is not available in the loaded ObjectBox runtime library.');
  }
  initializeDartAPI();

  final opt = checkObxPtr(C.admin_opt());
  try {
    checkObx(C.admin_opt_store(opt, InternalStoreAccess.ptr(store)));
    checkObx(C.admin_opt_user_management(opt, false));
    withNativeString(bindUri,
        (Pointer<Char> cStr) => checkObx(C.admin_opt_bind(opt, cStr)));
  } catch (_) {
    C.admin_opt_free(opt);
    rethrow;
  }

  _cAdmin = C.admin(opt);

  _finalizer.attach(this, _cAdmin.cast(),
      detach: this, externalSize: 1024 * 1024);
}