formatCountOrNull static method
Formats count as a badge string while capping overflow; returns null
when the count is absent or zero so callers can skip rendering.
Implementation
static String? formatCountOrNull(int? count,
{int cap = 99, String overflowLabel = '99+'}) {
if (count == null || count <= 0) {
return null;
}
if (count > cap) {
return overflowLabel;
}
return count.toString();
}