Skip to content
pubscout

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
$ flutter pub add sqflite_common_ffi
Source repository

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.

  • drift

    If you want a type-safe reactive SQL database library with code generation for Dart and Flutter.

  • hive_ce

    If you prefer a fast key-value NoSQL database instead of a relational SQL database.

Works with

Packages commonly used together with sqflite_common_ffi: ones it builds on, ones built on it, and its own family.