count method

int count(
  1. String value, [
  2. int start = 0,
  3. int? end
])

Count occurrences of value between start (inclusive) and end (exclusive).

Implementation

int count(String value, [int start = 0, int? end]) {
  final sub = (end == null) ? substring(start) : substring(start, end);
  return value.allMatches(sub).length;
}