canAdd method

bool canAdd(
  1. String categoryRaw
)

Returns true if another item from the given category can be added.

The categoryRaw string is canonicalized before checking against balances. Returns true for first-time categories (will be capped on first addItem call).

Used by UI to enable/disable "Add" buttons.

Implementation

bool canAdd(String categoryRaw) {
  final cat = _canon(categoryRaw);
  if (!balances.containsKey(cat)) return true; // first time seen -> allowed
  return _canAddCanon(cat);
}