expirationDate property

DateTime expirationDate

The Cart has an expiration date

The cart expiration date is the earliest item expiration date

Implementation

DateTime get expirationDate {
  // An empty cart never expires
  if (allItems.isEmpty) return null;

  // Get all items expiration dates
  var itemsExpirationDate =
      this.allItems.map((ci) => ci.expirationDate).toList();

  //Sort them
  itemsExpirationDate.sort((ldt, rdt) => ldt.compareTo(rdt));

  //Get the earlies expiration date
  return itemsExpirationDate.first;
}