The Cloud Firestore ODM is currently in alpha. Expect breaking changes, API changes and more. The documentation is still a work in progress. See the discussion for more details.
The Cloud Firestore ODM package enables developers to build fully type-safe applications for Flutter using the FlutterFire Cloud Firestore plugin.
The ODM allows data schemas to be defined which represent the data structure of your Cloud Firestore database. By defining schemas the ODM provides the following benefits:
- ↔️ Bi-directional data validation.
- 🔒 Type-safe data querying, supporting all Firestore query operations.
- 🔄 Flutter Widgets for simple data binding with your data.
- 🎯 Data selectors to help avoid unnecessary Widget rebuilds.
- 💻 Full API code completion.
The ODM relies on a recent Dart feature: generic annotations.
As such, to use the ODM you will need to upgrade your Dart SDK to enable this feature.
That is done by adding the following to your
Before getting started, ensure you have initialized FlutterFire.
The ODM depends on the
cloud_firestore plugin, so first ensure you have it installed on your project.
Next, install the
json_serializable packages as development dependencies:
Once installed, read the documentation on defining models.