resolveQualityFor method
Resolves the JPEG quality for a file of the given size, walking the
tier list in minBytes descending order. Tiers with null minBytes
are treated as catch-all and evaluated last.
Implementation
int resolveQualityFor(int fileBytes) {
final sorted = [...tiers]
..sort((a, b) => (b.minBytes ?? -1).compareTo(a.minBytes ?? -1));
for (final tier in sorted) {
if (tier.minBytes == null || fileBytes > tier.minBytes!) {
return tier.jpegQuality;
}
}
return 85;
}