get method

Object? get(
  1. AggregateField aggregateField
)

The result of aggregateField: an int, a double or null (for example the average over no numeric values).

On an Enterprise edition database the sum and the average over values that include a Decimal128Value are a Decimal128Value. getSum and getAverage convert it to the closest double.

Throws an ArgumentError if aggregateField was not requested.

final Object? sum = snapshot.get(AggregateField.sum('total'));

Implementation

Object? get(AggregateField aggregateField) {
  final FieldValue? value = _data[aggregateField.alias];
  if (value == null) {
    throw ArgumentError(
      "'${aggregateField.operator}(${aggregateField.fieldPath})' was not requested in the aggregation query.",
    );
  }
  return value.value;
}