FirebaseDatabase class Null safety

The entry point for accessing a Firebase Database. You can get an instance by calling FirebaseDatabase.instance or FirebaseDatabase.instanceFor().



FirebaseDatabase({FirebaseApp? app, String? databaseURL})
Returns an instance of FirebaseDatabase with the given FirebaseApp and/or [databaseURL).


app FirebaseApp
The FirebaseApp for this current FirebaseDatabase instance.
read / write
databaseURL String?
A custom Database URL for this instance.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
pluginConstants Map
Returns any plugin constants this plugin app instance has initialized.
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


goOffline() Future<void>
Shuts down our connection to the Firebase Database backend until goOnline is called.
goOnline() Future<void>
Resumes our connection to the Firebase Database backend after a previous goOffline call.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
purgeOutstandingWrites() Future<void>
The Firebase Database client automatically queues writes and sends them to the server at the earliest opportunity, depending on network connectivity. In some cases (e.g. offline usage) there may be a large number of writes waiting to be sent. Calling this method will purge all outstanding writes so they are abandoned. [...]
ref([String? path]) DatabaseReference
Returns a DatabaseReference representing the location in the Database corresponding to the provided path. If no path is provided, the Reference will point to the root of the Database.
reference() DatabaseReference
Returns a DatabaseReference accessing the root of the database.
@Deprecated('Deprecated in favor of calling `ref()`.')
refFromURL(String url) DatabaseReference
Returns a DatabaseReference representing the location in the Database corresponding to the provided Firebase URL.
setLoggingEnabled(bool enabled) → void
Enables verbose diagnostic logging for debugging your application. This must be called before any other usage of FirebaseDatabase instance. By default, diagnostic logging is disabled.
setPersistenceCacheSizeBytes(int cacheSize) → void
Attempts to set the size of the persistence cache. [...]
setPersistenceEnabled(bool enabled) → void
Attempts to sets the database persistence to enabled. [...]
toString() String
A string representation of this object. [...]
useDatabaseEmulator(String host, int port) → void
Changes this instance to point to a FirebaseDatabase emulator running locally. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Properties

instance FirebaseDatabase
Returns an instance using the default FirebaseApp.

Static Methods

instanceFor({required FirebaseApp app, String? databaseURL}) FirebaseDatabase
Returns an instance using a specified FirebaseApp.