isByteLength function

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

Checks if the string's UTF-8 byte length falls in a range.

The byte length must be at least min. If max is provided, it must also be at most max.

Example:

isByteLength('abc', 2); // true
isByteLength('abc', 4); // false
isByteLength('é', 1, 2); // true ('é' is 2 bytes in UTF-8)

Implementation

bool isByteLength(String str, int min, [int? max]) =>
    _isByteLength(str, min, max);