fireproof 0.0.2 copy "fireproof: ^0.0.2" to clipboard
fireproof: ^0.0.2 copied to clipboard

discontinued
outdated

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

fireproof (Work in progress) #

A builder used to create type safe bindings between models and Firestore. This package will likely stay in beta until static metaprogramming (currently in the language funnel of dartlang) is a thing and all builders here can be moved to that.

Getting Started #

This package builds type safe counterparts of DocumentReference, DocumentQuerySnapshot, etc.

After creating a base class, annotate a complementary class with @fireproof. 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
abstract class User with _$User {
  factory User({
    required UserBase data,
    required DocumentSnapshot snapshot,
  }) = _User;

  @Collection(name: 'badges')
  FireCollectionReference<BadgeBase, BadgeDoc> get badges;

  factory User.fromSnapshot(DocumentSnapshot snapshot) =>
      _$UserFromSnapshot(snapshot);
}

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