A package that provides a Brick compatible Cloud Firestore provider, repository, and code generation.
Brick Cloud Firestore is still in a pre-alpha release
- brick_cloud_firestore: Cloud Firestore connection classes.
- brick_cloud_firestore_abstract: Annotations and classes used to generate Cloud Firestore adapters. Exposes
ConnectOfflineFirstWithRest
for class level annotation and@CloudFirestore
for field level annotation. - brick_cloud_firestore_generator: Classes that generate code for annotated classes.
- brick_offline_first_with_cloud_firestore_build: Builder that generates code for all classes annotated with
ConnectOfflineFirstWithCloudFirestore
. Generates adapters and model dictionaries to support brick_offline_first and brick_cloud_firestore.
@ConnectOfflineFirstWithCloudFirestore
combines a sqlite cache, via Brick Offline First, and Cloud Firestore. By leveraging this annotation, we benefit from code generation that will build adapters for both data sources and DB schema migrations.
- Add the following packages:
brick_cloud_firestore:
git:
url: https://github.com/jnhuynh/brick_cloud_firestore.git
path: packages/brick_cloud_firestore
brick_offline_first: any
dev_dependencies:
build_runner: any
brick_offline_first_with_cloud_firestore_build:
git:
url: https://github.com/jnhuynh/brick_cloud_firestore.git
path: packages/brick_offline_first_with_cloud_firestore_build
$ flutter pub get
- Create an annotated model
import 'package:brick_cloud_firestore/cloud_firestore.dart';
@ConnectOfflineFirstWithCloudFirestore()
class Customer extends OfflineFirstWithCloudFirestoreModel {
final String firstName;
final String lastName;
Customer({
this.firstName,
this.lastName,
});
}
- Generate adapters and migrations.
$ flutter pub run build_runner build