sqflite-common-ffi-desktop

Configures sqflite databases on Windows, Linux, and macOS using the sqflite_common_ffi factory.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sqflite_common_ffi, sqlite3, and includes references (resource) components.

What problem does it solve? Running sqflite outside of Flutter mobile requires a different database factory, and developers hit errors like uninitialized global factories, missing native SQLite libraries, or blocked UI threads when they try to use the standard sqflite plugin on desktop or the Dart VM. ## Core Features & Use Cases - Desktop Database Factory: Initialize sqfliteFfiInit and databaseFactoryFfi so openDatabase works on Windows, Linux, macOS, CLI tools, and servers. - Isolate Control: Choose between the shared background sqflite isolate, a no-isolate synchronous factory, or a custom factory with ffiInit hooks and isolate port sharing. - Native Library Selection: Pick bundled SQLite, SQLCipher, or sqlite3mc encryption through sqlite3 v3 build hooks in pubspec.yaml. - Use Case: A Dart CLI application opens a persistent SQLite database at an absolute path, creates tables with onCreate versioning, and runs CRUD operations entirely on the Dart VM without Flutter. ## Quick Start Set up sqflite_common_ffi so I can open and query a SQLite database in my Dart command-line application on Linux.

Frequently Asked Questions about sqflite-common-ffi-desktop

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

FAQPage Schema
How do I use sqflite in a pure Dart application without Flutter?▼

Add sqflite_common_ffi to your dependencies, import package:sqflite_common_ffi/sqflite_ffi.dart, call sqfliteFfiInit() once, then open databases with databaseFactoryFfi.openDatabase(). This is the only way to use the sqflite API on the Dart VM.

How do I make the global openDatabase work on Flutter desktop?▼

Set databaseFactory = databaseFactoryFfi once before any global openDatabase() call, after calling sqfliteFfiInit(). Alternatively depend on the sqflite_ffi package, which registers the ffi factory automatically and shares the isolate between Flutter isolates.

Does sqflite_common_ffi work on the web?▼

No, databaseFactoryFfi throws UnsupportedError on the web. Use databaseFactoryFfiWeb from the sqflite_common_ffi_web package instead, which requires sqlite3.wasm and a worker file in your web directory.

Why do I get failed to load dynamic library with sqflite_common_ffi?▼

This happens when running plain dart file.dart, which skips build hooks that download the bundled SQLite library. Run dart run bin/main.dart once from a terminal so hooks execute and the library is cached under .dart_tool/hooks_runner/.

How do I encrypt a SQLite database with sqflite_common_ffi?▼

Set hooks.user_defines.sqlite3 source to sqlcipher or sqlite3mc in your application pubspec.yaml, then send PRAGMA key = 'your key' as the first statement in onConfigure when opening the database.

When should I use databaseFactoryFfiNoIsolate instead of databaseFactoryFfi?▼

Use databaseFactoryFfiNoIsolate inside a background isolate you already own, such as Isolate.run or compute, or in Flutter widget tests. In the main isolate of a UI app it runs SQLite synchronously and long queries block the UI.