createDatabaseFactoryFfi function

DatabaseFactory createDatabaseFactoryFfi({
  1. SqfliteFfiInit? ffiInit,
  2. bool noIsolate = false,
})

Creates an FFI database factory. Optionally the FFIInit function can be provided if you want to override some behavior with the sqlite3 dynamic library opening. This function should be either a top level function or a static function. Prefer the use of the databaseFactoryFfi getter if you don't need this functionality.

Example for overriding the sqlite library in Windows by providing a custom path.

import 'package:sqlite3/open.dart';

void ffiInit() {
  open.overrideFor(
    OperatingSystem.windows,
    () => DynamicLibrary.open('path/to/bundled/sqlite.dll'),
  );
}

Future<void> main() async {
  final dbFactory = createDatabaseFactoryFfi(ffiInit: ffiInit);
  final db = await dbFactory.openDatabase(inMemoryDatabasePath);
  ...
}

Implementation

DatabaseFactory createDatabaseFactoryFfi(
    {SqfliteFfiInit? ffiInit, bool noIsolate = false}) {
  return createDatabaseFactoryFfiImpl(ffiInit: ffiInit, noIsolate: noIsolate);
}