num sumField(String field) { num total = 0; for (final document in collection.values) { if (document[field] is num) { total += document[field]; } } return total; }