count property

int? get count

The result of the count aggregation (count() or AggregateField.count), or null when the query did not ask for it.

final int? n = (await firestore.collection('cities').count().get()).count;

Implementation

int? get count {
  final FieldValue? value = _data[AggregateField.count().alias];
  final Object? count = value?.value;
  return count is Int32Value ? count.value : (count as num?)?.toInt();
}