createSharedDatabase function

SharedDatabase createSharedDatabase(
  1. Ref<Object?> ref, {
  2. bool shouldDispose = true,
})

Creates a shared database, with dependencies obtained from the given ref.

Implementation

SharedDatabase createSharedDatabase(
  Ref ref, {
  bool shouldDispose = true,
}) {
  driftRuntimeOptions.dontWarnAboutMultipleDatabases = true;

  final database = SharedDatabase(ref.watch(connectionProvider));
  if (shouldDispose) {
    ref.onDispose(database.close);
  }

  return database;
}