sqflite_common_ffi
2.4.7, released 9 days ago by tekartik.com
FFI-based implementation of sqflite for desktop platforms and unit tests.
WASM-readyRock solid
What it does
Provides an sqflite-compatible database interface using the sqlite3 FFI package. Enables running SQLite databases on Windows, macOS, Linux, and during standard Flutter unit tests without device emulators.
AI-written summary of version 2.4.5, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need sqflite-based SQLite database support on Windows, macOS, or Linux.
- You want to write and execute unit tests involving sqflite without a physical device or emulator.
Skip it when
- You are building exclusively for mobile platforms where standard sqflite or drift is preferred.
- You require advanced reactive query streams out-of-the-box without extra boilerplate.
Strengths
- Brings familiar sqflite API to desktop platforms and unit tests.
- Database calls are executed in a separate isolate.
Weaknesses
- Requires platform-specific setup on Linux (libsqlite3 packages).
- Database calls in a separate isolate and multi-instance support is simulated.
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 5
Requires initializing with sqfliteFfiInit(). On Linux, requires installing libsqlite3 packages (e.g. libsqlite3-0 and libsqlite3-dev).
import 'package:test/test.dart';
import 'package:sqflite_common/sqlite_api.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
void main() {
sqfliteFfiInit();
test('simple sqflite example', () async {
var db = await databaseFactoryFfi.openDatabase(inMemoryDatabasePath);
expect(await db.getVersion(), 0);
await db.close();
});
}Alternatives
Packages that do the same job and could replace sqflite_common_ffi.
Works with
Packages commonly used together with sqflite_common_ffi: ones it builds on, ones built on it, and its own family.
- synchronizedsqflite_common_ffi depends on itLock mechanism to prevent concurrent access to asynchronous code.
- sqflite_commonsqflite_common_ffi depends on itDart wrapper on SQLite providing the common API for sqflite and desktop FFI implementations.
- sqlite3sqflite_common_ffi depends on itLightweight and convenient SQLite bindings for Dart using dart:ffi
- sqfliteSame familySQLite plugin for Flutter supporting iOS, Android and MacOS.
- sembastSame familyA NoSQL persistent embedded document-based database for Dart and Flutter.
- idb_shimSame familyCross-platform IndexedDB implementation for Dart and Flutter.
- process_runSame familyRun shell scripts and locate executables across Linux, Windows and macOS.
- sembast_webSame familyNoSQL persistent embedded database for the Web on top of IndexedDB.