sqflite
2.4.6, released 10 days ago by tekartik.com
SQLite plugin for Flutter supporting iOS, Android and MacOS.
Flutter FavoriteWASM-readyRock solid
What it does
Provides a self-contained, embedded SQL database engine for Flutter applications. Offers helpers for insert, query, update, and delete operations along with transaction and batch support.
AI-written summary of version 2.4.5, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a robust relational database with complex SQL queries on device.
- You want support for transactions and batch operations.
- You are targeting iOS, Android, and macOS platforms natively.
Skip it when
- You are looking for a simple key-value store without SQL queries.
- You prefer compile-time safe database queries via code generation.
Strengths
- Mature and widely used in the Flutter ecosystem.
- Supports transactions and batch execution for performance.
- Executes database operations in a background thread on iOS and Android.
Weaknesses
- Concurrent read and write transactions are not supported due to SQLite limitations.
- Does not support complex types like DateTime or bool natively out of the box.
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
Add to pubspec.yaml via flutter pub add sqflite. Linux, Windows, and Web require additional packages like sqflite_common_ffi or sqflite_common_ffi_web.
import 'package:sqflite/sqflite.dart';
var db = await openDatabase('my_db.db');
await db.transaction((txn) async {
int id1 = await txn.rawInsert('INSERT INTO Test(name, value, num) VALUES("some name", 1234, 456.789)');
});
await db.close();Alternatives
Packages that do the same job and could replace sqflite.
Works with
Packages commonly used together with sqflite: ones it builds on, ones built on it, and its own family.
- sqflite_commonsqflite depends on itDart wrapper on SQLite providing the common API for sqflite and desktop FFI implementations.
- sqflite_common_ffiSame familyFFI-based implementation of sqflite for desktop platforms and unit tests.
- sqflite_common_ffi_webSame familySqflite web implementation using sqlite3 ffi and sqlite3 wasm.
- sembast_sqfliteSame familySembast NoSQL database support built on top of sqflite for cross-process safety.
- idb_sqfliteSame familyIndexedDB API implementation on top of sqflite for Flutter and Dart VM
- flutter_cache_managerBuilt on sqfliteGeneric cache manager for saving web files and cache info on device storage.
- floorBuilt on sqfliteA SQLite abstraction library for Flutter inspired by Room.
- drift_sqfliteBuilt on sqfliteFlutter-only drift implementation using sqflite for SQLite storage.