database library

firebase_database_dart, for an app that depends on firebase_flutter_dart only. Get the instance with FirebaseFlutter.database.

Classes

DatabaseEvent
An event from one of the on<Thing> streams of a Query, or from Query.once.
DatabasePersistence
Persistence for one database instance: an opener of a storage engine plus the cache size. Build it with sqlitePersistence (package firebase_database_dart_sqlite) or, for your own engine, databasePersistence of package:firebase_database_dart/storage_engine.dart, and pass it as FirebaseDatabase(persistence: ...).
DatabaseReference
A location in the database. Creating one makes no request.
DataSnapshot
The data at a location at one moment, from an event, Query.get, Query.once or a transaction.
FirebaseDatabase
A connection to one Realtime Database of a FirebaseApp.
OnDisconnect
Writes the server applies to one location when this client's connection ends, from DatabaseReference.onDisconnect.
Query
A location with an optional order, range and limit. Immutable: every modifier returns a new query.
ServerValue
Values the server fills in when it applies a write.
Transaction
The answer of a TransactionHandler: write a new value with Transaction.success, or stop with Transaction.abort.
TransactionAbort
The Transaction.abort answer: stop with no write.
TransactionResult
What DatabaseReference.runTransaction completes with when the transaction did not fail.
TransactionSuccess
The Transaction.success answer: commit value and priority.

Enums

DatabaseErrorCode
The failure codes of a FirebaseDatabaseException, as a type you can switch on, with the public kebab-case code of each.
DatabaseEventType
The kind of a DatabaseEvent.
DatabaseLogLevel
How important a log message is.

Functions

mockUserTokenFor(String uid, {required String projectId, Map<String, Object?> claims = const <String, Object?>{}}) → String
Builds the mockUserToken that makes the Database emulator treat the client as the user uid.

Typedefs

DatabaseLogger = void Function(DatabaseLogLevel level, String message)
Receives log messages. Messages hold database paths, the shape of a query (its index name, such as the child path of orderByChild, which bounds are set, its limit), the host the client connects to, numbers (request numbers, write ids, socket close codes, cache sizes, timeouts), the type of a client-side error, a fixed reason, and the texts the server sent (status reasons, shutdown reasons, security debug output), also inside a database error.
TransactionHandler = Transaction Function(Object? currentValue)
Computes the new value of a location from its currentValue, for DatabaseReference.runTransaction.

Exceptions / Errors

FirebaseDatabaseException
Thrown, or passed to a stream's onError, when a Realtime Database operation fails.