FieldPath class

A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a top level field in the document), or a list of field names (referring to a nested field in the document).

Methods that take a field name as a String split it on dots. Use a FieldPath when a field name itself contains a dot or another character that a dotted path cannot hold (~ * / [ ]), and documentId to filter or sort by the document id.

final FieldPath nested = FieldPath(['address', 'city']); // same as 'address.city'
final FieldPath dotted = FieldPath(['version.1']); // one field named "version.1"

final QuerySnapshot<Map<String, Object?>> snapshot = await firestore
    .collection('cities')
    .where(nested, isEqualTo: 'San Francisco')
    .orderBy(dotted)
    .get();

Constructors

FieldPath(List<String> fieldNames)
Creates a FieldPath from the provided field names. If more than one field name is provided, the path will point to a nested field in a document.
factory
FieldPath.fromString(String path)
Parses a field path string into a FieldPath, treating dots as separators.
factory

Properties

components → List<String>
The field names of this path, one per nesting level: ['address', 'city'] for 'address.city'.
no setter
hashCode → int
The hash code for this object.
no setteroverride
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.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Properties

documentId → FieldPath
A special sentinel FieldPath to refer to the id of a document. It can be used in queries to sort or filter by the document id. This is documentId() of the JS SDK.
no setter