sqflite-common-ffi-async-factory

Implements concurrent SQLite reads on desktop using the sqlite_async-backed sqflite DatabaseFactory.

3.0k|555|Updated May 22, 2017
One-click install
npx skills add https://github.com/tekartik/sqflite --skill sqflite-common-ffi-async-factory-tekartik
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sqflite-common-ffi-async-factory
Source: https://github.com/tekartik/sqflite/tree/main/packages/sqflite_common_ffi_async/skills/sqflite-common-ffi-async-factory
Command: npx skills add https://github.com/tekartik/sqflite --skill sqflite-common-ffi-async-factory-tekartik

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sqflite_common_ffi, sqflite_common_ffi_async.

What problem does it solve? Standard sqflite_common_ffi runs all database operations on a single background isolate, so long write transactions block reads. This Skill explains how to use the experimental sqflite_common_ffi_async package, which backs the sqflite DatabaseFactory API with sqlite_async's connection pool (one writer, several readers) so reads never wait behind writes on Linux, macOS, and Windows. ## Core Features & Use Cases - Concurrent reads via readTransaction: Run read-only queries on a separate connection while a write transaction is still open, using db.readTransaction. - Drop-in DatabaseFactory API: databaseFactoryFfiAsync and databaseFactoryFfiAsyncTest expose the standard sqflite Database API (query, insert, transaction, batch), so existing code works unchanged. - Documented fallbacks and limits: In-memory and read-only databases fall back to databaseFactoryFfi; singleInstance is ignored, there is no logger support, and web is unsupported. - Use Case: A desktop Flutter app must display live query results while a long-running import transaction writes rows; use databaseFactoryFfiAsync with readTransaction so the UI reads are not blocked. ## Quick Start Show me how to open a database with databaseFactoryFfiAsync and run a readTransaction concurrently with a write transaction in my Dart desktop app.

Frequently Asked Questions about sqflite-common-ffi-async-factory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run concurrent reads during a write transaction in sqflite?▼

Use databaseFactoryFfiAsync from sqflite_common_ffi_async and call db.readTransaction for reads. It runs on a separate reader connection from the sqlite_async pool, so it executes while a write transaction is still open. Writes inside readTransaction throw a DatabaseException.

What is the difference between sqflite_common_ffi and sqflite_common_ffi_async?▼

sqflite_common_ffi runs all operations on a single background isolate, while sqflite_common_ffi_async uses sqlite_async's pool with one writer and several readers. The async version adds readTransaction for concurrent reads but ignores singleInstance and lacks logger support.

Does sqflite_common_ffi_async work on the web or mobile?▼

It is io-only, supporting Linux, macOS, Windows, Android, and iOS; calling it on the web throws UnsupportedError. For web, use sqflite_common_ffi_web instead. It targets Dart VM and Flutter desktop primarily.

How do I test code that uses databaseFactoryFfiAsync?▼

Use databaseFactoryFfiAsyncTest, a second independent factory instance for tests, with a file path and deleteDatabase in setUp. For tests not exercising readTransaction or concurrency, prefer databaseFactoryFfi from sqflite_common_ffi.

Why is singleInstance ignored in sqflite_common_ffi_async?▼

The async factory delegates opening and closing to sqlite_async's connection pool, so the sqflite singleInstance semantics (same Database object per path) are not honored. This is a documented limitation of the experimental package.