DatabaseReference class

DatabaseReference represents a particular location in your Firebase Database and can be used for reading or writing data to that location.

This class is the starting point for all Firebase Database operations. After you’ve obtained your first DatabaseReference via FirebaseDatabase.reference(), you can use it to read data (ie. onChildAdded), write data (ie. setValue), and to create new DatabaseReferences (ie. child).

Inheritance

Properties

hashCode int
The hash code for this object.
no setterinherited
key String
Gets the last token in a Firebase Database location (e.g. ‘fred’ in https://SampleChat.firebaseIO-demo.com/users/fred)
no setter
onChildAdded Stream<Event>
Fires when children are added.
no setterinherited
onChildChanged Stream<Event>
Fires when children are changed.
no setterinherited
onChildMoved Stream<Event>
Fires when children are moved.
no setterinherited
onChildRemoved Stream<Event>
Fires when children are removed. previousChildKey is null.
no setterinherited
onValue Stream<Event>
Fires when the data at this location is updated. previousChildKey is null.
no setterinherited
path String
Slash-delimited path representing the database location of this query.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

buildArguments() Map<String, dynamic>
inherited
child(String path) DatabaseReference
Gets a DatabaseReference for the location at the specified relative path. The relative path can either be a simple child key (e.g. ‘fred’) or a deeper slash-separated path (e.g. ‘fred/name/first’).
endAt(dynamic value, {String? key}) Query
Create a query constrained to only return child nodes with a value less than or equal to the given value, using the given orderBy directive or priority as default, and optionally only child nodes with a key less than or equal to the given key.
inherited
equalTo(dynamic value, {String? key}) Query
Create a query constrained to only return child nodes with the given value (and key, if provided).
inherited
get() Future<DataSnapshot>
Gets the most up-to-date result for this query.
inherited
keepSynced(bool value) Future<void>
By calling keepSynced(true) on a location, the data for that location will automatically be downloaded and kept in sync, even when no listeners are attached for that location. Additionally, while a location is kept synced, it will not be evicted from the persistent disk cache.
inherited
limitToFirst(int limit) Query
Create a query with limit and anchor it to the start of the window.
inherited
limitToLast(int limit) Query
Create a query with limit and anchor it to the end of the window.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
once() Future<DataSnapshot>
Listens for a single value event and then stops listening.
inherited
onDisconnect() OnDisconnect
orderByChild(String key) Query
Generate a view of the data sorted by values of a particular child key.
inherited
orderByKey() Query
Generate a view of the data sorted by key.
inherited
orderByPriority() Query
Generate a view of the data sorted by priority.
inherited
orderByValue() Query
Generate a view of the data sorted by value.
inherited
parent() DatabaseReference?
Gets a DatabaseReference for the parent location. If this instance refers to the root of your Firebase Database, it has no parent, and therefore parent() will return null.
push() DatabaseReference
Generates a new child location using a unique key and returns a DatabaseReference to it. This is useful when the children of a Firebase Database location represent a list of items.
reference() DatabaseReference
Obtains a DatabaseReference corresponding to this query's location.
inherited
remove() Future<void>
Remove the data at this Firebase Database location. Any data at child locations will also be deleted.
root() DatabaseReference
Gets a FIRDatabaseReference for the root location.
runTransaction(TransactionHandler transactionHandler, {Duration timeout = const Duration(seconds: 5)}) Future<TransactionResult>
Performs an optimistic-concurrency transactional update to the data at this Firebase Database location.
set(dynamic value, {dynamic priority}) Future<void>
Write value to the location with the specified priority if applicable.
setPriority(dynamic priority) Future<void>
Sets a priority for the data at this Firebase Database location.
startAt(dynamic value, {String? key}) Query
Create a query constrained to only return child nodes with a value greater than or equal to the given value, using the given orderBy directive or priority as default, and optionally only child nodes with a key greater than or equal to the given key.
inherited
toString() String
A string representation of this object.
inherited
update(Map<String, dynamic> value) Future<void>
Update the node with the value

Operators

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