countOccurrences method
Counts occurrences of a character in a string.
- Parameters:
- match: The character to count.
- caseSensitive: Whether the match is case-sensitive. Default is true.
- Returns: The count of the character.
Implementation
int countOccurrences(String match, {bool caseSensitive = true}) {
var count = 0;
for (final char in characters) {
if (caseSensitive ? char == match : char.equalsToIgnoreCase(match)) {
count++;
}
}
return count;
}