occurrences property

Map<String, int> get occurrences

Counts the occurrences of each character in the string.

@return A map where keys are characters and values are their occurrence counts.

Implementation

Map<String, int> get occurrences {
  final String str = removeWhitespace;
  return str.split('').fold(<String, int>{},
      (Map<String, int> map, String char) {
    map[char] = (map[char] ?? 0) + 1;
    return map;
  });
}