countOf method

int countOf(
  1. String other
)

Number of times other appears. "banana".countOf("a") → 3

Implementation

int countOf(String other) => other.isEmpty ? 0 : RegExp(RegExp.escape(other)).allMatches(this).length;