namedQueryGet method
Future<QuerySnapshot<Map<String, Object?> > >
namedQueryGet(
- String name, {
- GetOptions options = const GetOptions(),
Runs the named query name of a loaded bundle (see namedQuery) and returns its results: FlutterFire's
namedQueryGet.
The future fails with a FirestoreException with FirestoreErrorCode.notFound when the cache has no query with this name.
final QuerySnapshot<Map<String, Object?>> stories = await firestore
.namedQueryGet(
'latest-stories',
options: const GetOptions(source: Source.cache),
);
Implementation
Future<QuerySnapshot<Map<String, Object?>>> namedQueryGet(
String name, {
GetOptions options = const GetOptions(),
}) async {
final Query<Map<String, Object?>>? query = await namedQuery(name);
if (query == null) {
throw FirestoreException(
errorCode: FirestoreErrorCode.notFound,
message: 'Named query "$name" not found.',
);
}
return query.get(options);
}