import 'package:flutter/material.dart'; /* todo: - Flag für Ansicht/Bearbeitung - individuelle Icons je nach Kategorie - Pfand - Gesamtpreis */ enum Unit { stueck, menge } enum Category { obstUndGemuese, brotCerealienUndAufstriche, getraenke, drogerieUndHaushalt, kochenUndBacken, oeleSossenUndGewuerze, suessesUndKnabbereien } class Product { final int id = 0; final String name; final Unit unit; final double price; //pro Kilogramm oder Stück final double vat; final Category category; const Product(this.name, this.unit, this.price, this.vat, this.category); } class Purchase { Product product; int amount; Purchase(this.product, this.amount); } class Basket { List purchases; int price; Basket(this.purchases, this.price); } class ShowBasket extends StatelessWidget { ShowBasket({super.key}); //sample data static const List products = [ Product('Apfel', Unit.stueck, 0.23, 7, Category.obstUndGemuese), Product('Mehl', Unit.menge, 0.003, 19, Category.kochenUndBacken), Product('Brot', Unit.stueck, 1.23, 7, Category.brotCerealienUndAufstriche), Product('Milch', Unit.stueck, 2.23, 3, Category.getraenke), Product('Zahnpasta', Unit.stueck, 0.23, 7, Category.drogerieUndHaushalt), Product('Pfeffer', Unit.stueck, 0.23, 7, Category.oeleSossenUndGewuerze), Product('Schokolade', Unit.menge, 0.23, 7, Category.suessesUndKnabbereien) ]; Basket basket = Basket([ Purchase(products[0], 20), Purchase(products[1], 2200), Purchase(products[2], 2), Purchase(products[3], 1), Purchase(products[4], 1), Purchase(products[5], 2), Purchase(products[6], 202) ], 304); @override Widget build(BuildContext context) { return ListView.builder( itemCount: null, itemBuilder: (context, index) { if (index < basket.purchases.length) { return Card( child: ListTile( leading: const Icon(Icons.abc), title: Text(basket.purchases[index].product.name), //trailing: Text(), ), ); } else { return null; } }, ); } }