get method

Future<AggregateQuerySnapshot> get({
  1. AggregateSource source = AggregateSource.server,
})

Executes the aggregation on the server and returns the results.

Aggregations are never computed from the local cache: when the client is offline the returned Future fails with a FirestoreException whose code is unavailable. source can only be AggregateSource.server, the default. A failure is not retried; other errors of the backend (for example failedPrecondition for a missing index, or permissionDenied) fail the Future with their code.

final AggregateQuerySnapshot snapshot = await firestore
    .collection('cities')
    .aggregate(<AggregateField>[AggregateField.sum('population')])
    .get();

Implementation

Future<AggregateQuerySnapshot> get({
  AggregateSource source = AggregateSource.server,
}) async {
  final Map<String, FieldValue> data = await query.firestore.client
      .runAggregateQuery(query.query, aggregateFields);
  return AggregateQuerySnapshotInternal.create(this, data);
}