FirebaseDocument<T> class
A type-safe wrapper for Firestore documents.
Provides strongly-typed access to document operations and subcollections.
The generic type T represents the model class for this document.
Example:
// Create a typed document reference
final userDoc = FirebaseDocument<User>(
path: 'users/123',
fromJson: User.fromJson,
);
// Get user data
final user = await userDoc.get();
if (user != null) {
print('User name: ${user.name}');
}
Constructors
-
FirebaseDocument({required String path, required T fromJson(Map<
String, dynamic> , String), FirebaseFirestore? firestore}) - Creates a new FirebaseDocument 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 document in Firestore (e.g., 'users/123')
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
collection<
R> (String collectionPath, R fromJson(Map< String, dynamic> , String)) → FirebaseCollection<R> - Gets a reference to a subcollection of this document.
-
delete(
) → Future< void> - Deletes the document.
-
get(
) → Future< T?> - Gets the document data.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
Map< String, dynamic> data, {bool merge = false}) → Future<void> - Sets the document data.
-
stream(
) → Stream< T?> - Gets a real-time stream of the document data.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
Map< String, dynamic> data) → Future<void> - Updates specific fields in the document.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited