count method

int count(
  1. String value, [
  2. bool caseSensitive = true
])

Implementation

int count(String value, [bool caseSensitive = true]) {
  if (value.isEmpty) {
    return 0;
  }
  return length - (caseSensitive ? replaceAll(value, '') : toLowerCase().replaceAll(value.toLowerCase(), '')).length;
}