openStore function

Future<Store> openStore({
  1. String? directory,
  2. int? maxDBSizeInKB,
  3. int? maxDataSizeInKB,
  4. int? fileMode,
  5. int? maxReaders,
  6. bool queriesCaseSensitiveDefault = true,
  7. String? macosApplicationGroup,
})

Shortcut for obx.Store.new that passes getObjectBoxModel and for Flutter apps by default a directory using defaultStoreDirectory() from the ObjectBox Flutter library.

Note: for desktop apps it is recommended to specify a unique directory.

See obx.Store.new for an explanation of all parameters.

For Flutter apps, also calls loadObjectBoxLibraryAndroidCompat() from the ObjectBox Flutter library to fix loading the native ObjectBox library on Android 6 and older.

Implementation

Future<obx.Store> openStore({
  String? directory,
  int? maxDBSizeInKB,
  int? maxDataSizeInKB,
  int? fileMode,
  int? maxReaders,
  bool queriesCaseSensitiveDefault = true,
  String? macosApplicationGroup,
}) async {
  await loadObjectBoxLibraryAndroidCompat();
  return obx.Store(
    getObjectBoxModel(),
    directory: directory ?? (await defaultStoreDirectory()).path,
    maxDBSizeInKB: maxDBSizeInKB,
    maxDataSizeInKB: maxDataSizeInKB,
    fileMode: fileMode,
    maxReaders: maxReaders,
    queriesCaseSensitiveDefault: queriesCaseSensitiveDefault,
    macosApplicationGroup: macosApplicationGroup,
  );
}