Cindel gives Flutter apps a fully generated typed database API backed by MDBX on native platforms and SQLite/OPFS on the web. This guide walks through everything from adding the packages to your pubspec all the way to querying live data — you will have a working local database in your Flutter project in under five minutes.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mainser/cindel/llms.txt
Use this file to discover all available pages before exploring further.
Flutter Web requires a few additional setup steps for the Worker and Wasm assets provided by
cindel_flutter_libs. See the Installation page for the complete platform-specific guide.Add Dependencies
Open your project’s
pubspec.yaml and add cindel and cindel_flutter_libs as runtime dependencies, then add build_runner and cindel_generator as dev dependencies.cindel_flutter_libs carries no public Dart API. It is present so Flutter’s platform build can find and bundle the prebuilt native libraries on Android, iOS, macOS, Windows, and Linux, and the Worker/Wasm assets for Flutter Web. No import from this package is required in your application code.Define a Model
Create a Dart file for your model. Add a
part directive for the generated file, import package:cindel/cindel.dart, and annotate the class with @Collection. Every collection must declare exactly one Id field named dbId; set it to autoIncrement so Cindel assigns ids automatically.@Index(unique: true) on email tells the generator to produce a unique index and a putByEmail upsert helper. @Index() on name produces range-style query helpers. Fields without an annotation are still persisted — they just cannot be used in generated where() index lookups.Run the Generator
Run During active development, use After the command completes, a
build_runner from your project root to produce the user.g.dart part file. The generator emits the collection schema, serializers, typed collection accessor, where() index helpers, and filter() query helpers.watch mode to regenerate automatically whenever you save a model file:user.g.dart file appears next to user.dart. Commit both files to version control.Open the Database
Call
Cindel.open with the path to a writable directory and the list of schemas produced by the generator. On native platforms, Cindel uses MDBX by default. Pass additional schemas to the list as your model count grows.Cindel.open is async and returns a CindelDatabase. Keep the returned handle alive for the lifetime of your app, and call db.close() only when you are fully done with the database (for example, in a test teardown or app shutdown hook).Write and Read Data
With a After
CindelDatabase in hand, access the generated users collection directly from the database object. All collection methods are async.put, Cindel writes the assigned auto-increment id back to user.dbId, so you can pass that id directly to get without an additional query.