isInSizes function
Check a file size value within a specified range min, max.
print(isInSizes(5)); // false (no range defined)
print(isInSizes(5, min: 3, max: 7)); // true (within range)
print(isInSizes(2, min: 3, max: 7)); // false (not within range)
print(isInSizes(5, min: 3)); // true (greater than or equal to min)
print(isInSizes(2, min: 3)); // false (not greater than or equal to min)
print(isInSizes(5, max: 7)); // true (less than or equal to max)
print(isInSizes(8, max: 7)); // false (not less than or equal to max)
Implementation
bool isInSizes(int value, {int? min, int? max}) {
// Condition 1: No range defined
if (min == null && max == null) return false;
// Condition 2: Within range
if (min != null && max != null) return value >= min && value <= max;
// Condition 3: Greater than or equal to min
if (min != null) return value >= min;
// Condition 4: Less than or equal to max
return value <= max!; // max != null
}