Skip to main content
This guide walks you through every step to get Cindel running in a Flutter app from scratch. By the end you will have a persistent Todo collection with typed reads, writes, and a reactive watcher — all driven by generated Dart code.
1

Add dependencies

Open your 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
Run flutter pub get after saving the file.
2

Define a model

Create a Dart file for your model. Annotate the class with @Collection(), declare an Id dbId = autoIncrement field, and add a part directive for the file that build_runner will generate.
todo.dart
Add @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 todo.g.dart. This file contains the TodoSchema constant, the db.todos getter, serializers, and all typed query helpers.
During active development, use 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.
For unit tests, use Cindel.openInMemory(schemas: [TodoSchema]) instead of Cindel.open. In-memory databases are fast to create, require no filesystem path, and are automatically discarded when closed — making them ideal for isolated test cases.

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 Datawhere(), filter(), sorting, pagination, projections, and aggregates.
  • Transactions — group related writes with writeTxn so they commit or roll back atomically.
  • Flutter Web — run the same typed code in the browser with SQLite Web/OPFS.