remaining property
The more-restrictive window's remaining budget. Returns null if all caps are unlimited.
Implementation
int? get remaining {
int? daily = dailyCap != null
? (dailyCap! - dayCount).clamp(0, dailyCap!)
: null;
int? weekly = weeklyCap != null
? (weeklyCap! - weekCount).clamp(0, weeklyCap!)
: null;
int? total = totalCap != null
? (totalCap! - totalCount).clamp(0, totalCap!)
: null;
// Return the smallest non-null value.
final caps = [daily, weekly, total].whereType<int>().toList();
if (caps.isEmpty) return null;
return caps.reduce((a, b) => a < b ? a : b);
}