1
0
Fork 0
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.
 
 
 
 
 
thesis_shop/lib/stores/product_selection_store.dart

31 lines
961 B

import 'package:flutter/material.dart';
import 'package:thesis_shop/models/product.dart';
class ProductSelectionStore extends InheritedWidget {
const ProductSelectionStore({
Key? key,
required this.products,
required this.productAmounts,
required this.increaseAmount,
required this.decreaseAmount,
required Widget child,
}) : super(key: key, child: child);
final List<Product> products;
final Map<ProductTitle, int> productAmounts;
final Function(Product) increaseAmount;
final Function(Product) decreaseAmount;
static ProductSelectionStore of(BuildContext context) {
final ProductSelectionStore? result =
context.dependOnInheritedWidgetOfExactType<ProductSelectionStore>();
assert(result != null, 'No ProductSelectionStore found in context');
return result!;
}
@override
bool updateShouldNotify(ProductSelectionStore oldWidget) {
return productAmounts != oldWidget.productAmounts;
}
}