isLength function

bool isLength(
  1. String str,
  2. int min,
  3. [int max]
)

check if the string's length falls in a range

Note: this function takes into account surrogate pairs.

Implementation

bool isLength(String str, int min, [int max]) {
  List surrogatePairs = _surrogatePairsRegExp.allMatches(str).toList();
  int len = str.length - surrogatePairs.length;
  return len >= min && (max == null || len <= max);
}