fireproof 0.0.1+1 copy "fireproof: ^0.0.1+1" to clipboard
fireproof: ^0.0.1+1 copied to clipboard

discontinued
outdated

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
1
likes
0
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A builder used to create type safe bindings between models and Firestore

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, build, fireproof_annotation, meta, source_gen, strings

More

Packages that depend on fireproof