getUniqueShoppingCategories function
- List<
CreditCard> cards
Implementation
List<ShoppingCategory> getUniqueShoppingCategories(List<CreditCard> cards) {
Map<String, bool> promoIdDict = {};
List<ShoppingCategory> uniqueCategories = [];
for (CreditCard card in cards) {
for (Promotion promo in card.promotions) {
if (!promoIdDict.containsKey(promo.id)) {
promoIdDict[promo.id] = true;
uniqueCategories.add(promo.category);
}
}
}
return uniqueCategories;
}