createDatabaseFactoryFfi function
DatabaseFactory
createDatabaseFactoryFfi({
- SqfliteFfiInit? ffiInit,
- bool noIsolate = false,
- SqfliteFfiIsolatePortServer? isolatePortServer,
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);
...
}
If isolatePortServer is provided (not supported on the web), it is used
to share the sqflite isolate between isolates, typically using Flutter
IsolateNameServer (see the sqflite_ffi package).
Implementation
DatabaseFactory createDatabaseFactoryFfi({
SqfliteFfiInit? ffiInit,
bool noIsolate = false,
SqfliteFfiIsolatePortServer? isolatePortServer,
}) {
return createDatabaseFactoryFfiImpl(
ffiInit: ffiInit,
noIsolate: noIsolate,
isolatePortServer: isolatePortServer,
);
}