Fb class
The main entry point for the Firestore wrapper functionality.
This class provides static methods to create typed collection references, run transactions, and perform batch operations with Firestore.
Example:
// Create a typed collection
final usersCollection = Fb.collection<User>(
'users',
User.fromJson,
);
// Run a transaction
final newPoints = await Fb.runTransaction((transaction) async {
final userData = await transaction.get('users/123');
final currentPoints = userData?['points'] as int? ?? 0;
transaction.update('users/123', {'points': currentPoints + 100});
return currentPoints + 100;
});
// Perform batch operations
final batch = Fb.batch();
batch.set('users/123', {'status': 'active'});
batch.delete('users/456');
await batch.commit();
Constructors
- Fb()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
batch(
) → FbBatch - Creates a new batch operation for performing multiple writes atomically.
-
collection<
T> (String path, T fromJson(Map< String, dynamic> , String)) → FirebaseCollection<T> - Creates a typed collection reference.
-
logError(
String message, dynamic e) → Future< void> - Logs an error that occurred during a Firestore operation.
-
runTransaction<
T> (Future< T> transactionHandler(FbTransaction)) → Future<T> - Runs a transaction that can both read and write data atomically.