fireproof 0.0.1+1
fireproof: ^0.0.1+1 copied to clipboard
A builder used to create type safe bindings between models and Firestore
fireproof #
A builder used to create type safe bindings between models and Firestore.
Getting Started #
This package builds type safe counterparts of DocumentReference, DocumentQuerySnapshot, etc.
After creating a base class, annotate a complementary class with @fireproof and expand from _$Class. This class will in theory be a QuerySnapshot whose dynamic data()? will be replaced by Model data.
@freezed
class UserBase with _$UserBase {
const factory UserBase({
required String name,
required String email,
}) = _UserBase;
factory UserBase.fromJson(Map<String, dynamic> json) =>
_$UserBaseFromJson(json);
}
@fireproof
class User extends _$User {
final UserBase data;
User({
required this.data,
required DocumentSnapshot snapshot,
}) : super(snapshot);
factory User.fromSnapshot(DocumentSnapshot snapshot) =>
_$UserFromSnapshot(snapshot);
@Collection(name: 'badges')
late final FireCollectionReference<BadgeBase, Badge> badgesCollection;
}
Now run
flutter pub run build_runner