countByField method

Map<String, int> countByField(
  1. String field
)

Implementation

Map<String, int> countByField(String field) {
  Map<String, int> etypeCounts = {};

  this.forEach((day, events) {
    if (events is Map<String, dynamic>) {
      events.forEach((id, event) {
        if (event[field] != null) {
          String title = event[field];
          etypeCounts[title] = (etypeCounts[title] ?? 0) + 1;
        }
      });
    }
  });

  return etypeCounts;
}