Todo collection with typed reads, writes, and a reactive watcher — all driven by generated Dart code.
1
Add dependencies
Open your Run
pubspec.yaml and add the four Cindel packages. The cindel and cindel_flutter_libs packages are runtime dependencies; build_runner and cindel_generator are used only during development to generate code.pubspec.yaml
flutter pub get after saving the file.2
Define a model
Create a Dart file for your model. Annotate the class with Add
@Collection(), declare an Id dbId = autoIncrement field, and add a part directive for the file that build_runner will generate.todo.dart
@Index() to any field you plan to use with the generated where() helper for fast indexed lookups. Fields without an index are still fully queryable through filter().3
Generate code
Run the code generator once to produce During active development, use
todo.g.dart. This file contains the TodoSchema constant, the db.todos getter, serializers, and all typed query helpers.watch mode so the generator re-runs automatically whenever you edit a model:Never hand-edit the generated
*.g.dart files. Re-run the generator any time you change a model class or its annotations.4
Open the database and use it
Resolve a writable directory with
path_provider, open the database with the generated TodoSchema, and then read and write through the typed db.todos collection.When
dbId is set to autoIncrement, Cindel assigns a new id the first time you call put. After put returns, the generated id setter writes the allocated id back to the todo object, so todo.dbId contains the real persisted id immediately.What to explore next
Now that your first collection is working, explore the rest of the Cindel feature set:- Installation — full package details, backend selection, and platform support.
- Data Modeling — field types, enums, embedded objects, indexes, and Freezed support.
- Querying Data —
where(),filter(), sorting, pagination, projections, and aggregates. - Transactions — group related writes with
writeTxnso they commit or roll back atomically. - Flutter Web — run the same typed code in the browser with SQLite Web/OPFS.