You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
890 B
25 lines
890 B
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:thesis_shop/models/product.dart';
|
|
import 'package:thesis_shop/store/cart_store.dart';
|
|
import 'package:thesis_shop/widgets/number_picker.dart';
|
|
|
|
class ProductItem extends StatelessWidget {
|
|
final Product product;
|
|
const ProductItem({Key? key, required this.product}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final numberOfProduct = context
|
|
.select<CartStore, int>((store) => store.amountOfProduct(product));
|
|
final cartStore = context.read<CartStore>();
|
|
return ListTile(
|
|
title: Text('${product.title} (${product.priceAsString}€/Stück)'),
|
|
trailing: NumberPicker(
|
|
value: numberOfProduct,
|
|
onUp: () => cartStore.increaseAmount(product),
|
|
onDown: () => cartStore.decreaseAmount(product),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|