FirebaseCollection<T> class

A type-safe wrapper for Firestore collections.

Provides strongly-typed access to collection operations and queries. The generic type T represents the model class for documents in this collection.

Example:

// Create a typed collection for User documents
final usersCollection = FirebaseCollection<User>(
  path: 'users',
  fromJson: User.fromJson,
);

// Add a new user
final userId = await usersCollection.add({
  'name': 'John Doe',
  'email': 'john@example.com',
});

// Get a user document
final userDoc = usersCollection.doc(userId);

Constructors

FirebaseCollection({required String path, required T fromJson(Map<String, dynamic>, String), FirebaseFirestore? firestore})
Creates a new FirebaseCollection instance.

Properties

fromJson → T Function(Map<String, dynamic>, String)
Function to convert Firestore data to type T
final
hashCode int
The hash code for this object.
no setterinherited
path String
The path to this collection in Firestore
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(Map<String, dynamic> data) Future<String>
Adds a new document to the collection.
collection<R>(String collectionPath, R fromJson(Map<String, dynamic>, String)) FirebaseCollection<R>
Creates a subcollection reference.
doc([String? id]) FirebaseDocument<T>
Gets a reference to a document in this collection.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query() FirebaseQuery<T>
Creates a query builder for this collection.
stream() Stream<List<T>>
Gets a real-time stream of all documents in the collection.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited