isWithinLength method
Length bounded — prevents silent acceptance of huge inputs.
Implementation
bool isWithinLength({required int min, required int max}) {
if (min < 0) {
throw ArgumentError.value(min, 'min', 'must not be negative');
}
if (max < min) {
throw ArgumentError.value(
max,
'max',
'must be greater than or equal to min',
);
}
return length >= min && length <= max;
}