average static method

AverageAggregateField average(
  1. Object field
)

Creates an AggregateField that averages the values of field over the documents in the result set. The result is a double, or null if no document has a numeric value for the field.

field is a String, a dot-separated field path, or a FieldPath; it throws an ArgumentError if it is not a valid path.

final AggregateQuerySnapshot result = await firestore
    .collection('orders')
    .aggregate(<AggregateField>[AggregateField.average('total')])
    .get();
final double? average = result.getAverage('total');

Implementation

static AverageAggregateField average(Object field) =>
    AverageAggregateField._(_fieldPathOf('average', field));