realm
20.2.0, released a year ago by realm.io
A local NoSQL database for Flutter/Dart with object‑oriented API and live query streams.
What it does
Realm stores data on‑device using a schema‑based object model. It provides fast CRUD operations, live query change streams, and automatic synchronization (now deprecated). The SDK generates Dart model classes from annotated definitions.
AI-written summary of version 20.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a high‑performance on‑device database with live updates
- You prefer an object‑oriented API over raw SQL
- You want automatic schema migrations and type safety
Skip it when
- Device Sync is required (sync features are removed)
- You need a pure key‑value store or minimal footprint
- You target web only (no native support)
Strengths
- Fast native performance, often faster than SQLite
- Live query change streams simplify reactive UI
- Schema defined in Dart, code‑gen reduces boilerplate
- Cross‑platform support including desktop
Weaknesses
- Requires native build steps (CMake, Cocoapods)
- Sync functionality deprecated, future‑proofness uncertain
- Larger binary size compared to simple key‑value packages
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 1
Run `dart run realm install` to fetch native binaries; ensure CMake ≥ 3.21, Cocoapods ≥ 1.11, and Flutter ≥ 3.10.2. Add `realm` to pubspec and generate model code with `dart run realm generate`.
import 'package:realm/realm.dart';
part 'app.realm.dart';
@RealmModel()
class _Car {
late String make;
late String model;
int? kilometers = 500;
}
void main() {
var config = Configuration.local([Car.schema]);
var realm = Realm(config);
var car = Car('Tesla', 'Model Y', kilometers: 5);
realm.write(() => realm.add(car));
var cars = realm.all<Car>().query(r'make == $0', ['Tesla']);
cars.changes.listen((c) => print('Inserted: ${c.inserted}'));
}Alternatives
Packages that do the same job and could replace realm.
Works with
Packages commonly used together with realm: ones it builds on, ones built on it, and its own family.