create static method

Future<AliceObjectBoxStore> create({
  1. Store? store,
  2. bool persistent = true,
})

Create an instance of AliceObjectBoxStore to use throughout the app.

Implementation

static Future<AliceObjectBoxStore> create({
  Store? store,
  bool persistent = true,
}) async {
  final String storeDirectoryPath = path.join(
    (await getApplicationDocumentsDirectory()).path,
    Store.defaultDirectoryPath,
    "alice",
  );

  final Directory storeDirectory = Directory(storeDirectoryPath);
  if (!await storeDirectory.exists()) {
    await storeDirectory.create(recursive: true);
  }

  store ??= Store.isOpen(storeDirectoryPath)
      ? Store.attach(getObjectBoxModel(), storeDirectoryPath)
      : await openStore(directory: storeDirectoryPath);

  return AliceObjectBoxStore._create(store, persistent: persistent);
}