isLength method

bool isLength(
  1. int min, [
  2. int? max
])

Check if the string's length falls in a range If no max is given then any length above min is ok.

Note: this function takes into account surrogate pairs.

Implementation

bool isLength(int min, [int? max]) {
  var str = this;

  final surrogatePairs = RegexUtils.surrogatePairs.allMatches(str).toList();
  int len = str.length - surrogatePairs.length;
  return len >= min && (max == null || len <= max);
}