charCount method
Finds a specific's character occurence in a string.
Example
String foo = 'foo';
int occ = foo.charCount('o'); // returns 2
Implementation
int? charCount(String char) {
if (this == null) return null;
if (this!.isEmpty) return 0;
return this!.split('').fold<int>(
0,
(previousValue, ch) => previousValue + (ch == char ? 1 : 0),
);
}