lines method

List<CartLine> lines(
  1. PosQuantity mode
)

Zeilen fuer die Anzeige je Mengenmodus: PosQuantity.off loest gebuendelte Positionen in eine Zeile je Stueck zum Einzelpreis auf.

Implementation

List<CartLine> lines(PosQuantity mode) {
  if (mode != PosQuantity.off) {
    return items
        .map((p) => CartLine(key: p.id, item: p, quantity: p.quantity, amountCents: p.lineTotalCents))
        .toList();
  }
  return [
    for (final p in items)
      for (var i = 0; i < (p.quantity < 1 ? 1 : p.quantity); i++)
        CartLine(key: '${p.id}#$i', item: p, quantity: 1, amountCents: p.priceCents),
  ];
}