Recently I came accross this nice database you can give it a quick read.
What is Isar?
Isar is a fast, fully asynchronous NoSQL database optimized for Flutter and Dart. It runs locally on mobile, desktop, and web platforms with a native Dart API. Isar is designed to be simple, scalable, performant, and developer-friendly, with built-in support for reactive queries and complex filtering.
Features of Isar:
• NoSQL document database designed for embedded use (runs inside your app with zero external dependencies).
• Supports schema definition using Dart classes with annotations.
• Provides full reactive queries, UI updates automatically on data changes.
• Compact, high-performance transactions for fast and safe reads/writes.
• Full text search with token based indexing for searching text fields.
• Composite and multi-entry indexes for structured queries.
• Supports JSON serialization and deserialization.
• Comes with a visual inspector for debugging database contents in debug mode.
• Cross-platform support for Android, iOS, Web, Desktop platforms.
Transactions in Isar
Isar enforces safe and atomic transactions.
- Writes must be wrapped in a
writeTxn
transaction. - Reads are async and safe by default.
This ensures data integrity and prevents inconsistent states.
Example:
final isar = await Isar.open([UserSchema]); await isar.writeTxn(() async { final user = User()..name = 'Alice'..age = 25; await isar.users.put(user); // insert or update }); final users = await isar.users.filter().ageGreaterThan(20).findAll(); print(users);
Getting Started
Step 1 : Add Isar to your project:
dependencies: isar: any isar_flutter_libs: any path_provider: any dev_dependencies: isar_generator: any build_runner: any
Step 2 : Define your model with annotations:
import 'package:isar/isar.dart'; part 'user.g.dart'; @collection class User { Id id = Isar.autoIncrement; late String name; late int age; }
Step 3 : Run build:
flutter pub run build_runner build
That’s it! You now have a fully working local NoSQL database integrated into your Flutter app.
Learn from the official documentation: https://isar.dev/tutorials/quickstart.html
Top comments (0)