totalValue static method

double totalValue(
  1. List<CartItemModel> items
)

Implementation

static double totalValue(List<CartItemModel> items) {
  if (items.isEmpty) return 0;
  var value = items
      .map((item) =>
          item.amount! *
          ((item.product != null) && (item.product!.price != null)
              ? item.product!.price!
              : 0.0))
      .reduce((value, element) => value + element);
  return value.toDouble();
}