charCount function

int charCount(
  1. String str, {
  2. bool filterNonChars = true,
})

Counts the number of characters in str.

filterNonChars removes non-chars from count.

Implementation

int charCount(String str, {bool filterNonChars = true}) {
  if (filterNonChars) {
    return str.runes.where(isChar).length;
  } else {
    return str.runes.length;
  }
}