DocumentReference class Null safety

A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist.

A DocumentReference can also be used to create a CollectionReference to a subcollection.



firestore Firestore
Non-null Firestore the document is in. This is useful for performing transactions, for example.
hashCode int
The hash code for this object. [...]
read-only, inherited
id String
The document's identifier within its collection.
jsObject → DocumentReferenceJsImpl
JS object.
final, inherited
onMetadataChangesSnapshot Stream<DocumentSnapshot>
Attaches a listener for DocumentSnapshot events with {includeMetadataChanges: true} - raise an event even if only metadata of the document changed. Default is false.
onSnapshot Stream<DocumentSnapshot>
Attaches a listener for DocumentSnapshot events.
parent CollectionReference
Non-null CollectionReference. The Collection this DocumentReference belongs to.
path String
The document's path within its collection.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


collection(String collectionPath) CollectionReference
Gets a CollectionReference instance that refers to the collection at the specified path. [...]
delete() Future<void>
Deletes the document referred to by this DocumentReference. [...]
get() Future<DocumentSnapshot>
Reads the document referred to by this DocumentReference. Note: get() attempts to provide up-to-date data when possible by waiting for data from the server, but it may return cached data or fail if you are offline and the server cannot be reached. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
set(Map<String, dynamic> data, [SetOptions? options]) Future<void>
Writes to the document referred to by this DocumentReference. If the document does not exist yet, it will be created. If you pass options, the provided data can be merged into the existing document. [...]
toString() String
A string representation of this object. [...]
update({Map<String, dynamic>? data, List? fieldsAndValues}) Future<void>
Updates fields in the document referred to by this DocumentReference. The update will fail if applied to a document that does not exist. [...]


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

Static Methods

getInstance(DocumentReferenceJsImpl jsObject) DocumentReference
Creates a new DocumentReference from a jsObject.