mode property
T?
get
mode
Returns the most frequently occurring element, or null if empty.
Implementation
T? get mode {
if (isEmpty) return null;
final freq = <T, int>{};
for (final e in this) {
freq[e] = (freq[e] ?? 0) + 1;
}
return freq.entries.reduce((a, b) => a.value >= b.value ? a : b).key;
}