isByteLength function

bool isByteLength(
  1. String str, {
  2. dynamic min = 0,
  3. dynamic max,
})

check if the string's length (in bytes) falls in a range.

Implementation

bool isByteLength(String str, {min = 0, max}) {
  var len = Uri.encodeFull(str).split(r'/%..|./').length - 1;
  return len >= min && (max == null || len <= max);
}