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 products; final Map productAmounts; final Function(Product) increaseAmount; final Function(Product) decreaseAmount; static ProductSelectionStore of(BuildContext context) { final ProductSelectionStore? result = context.dependOnInheritedWidgetOfExactType(); assert(result != null, 'No ProductSelectionStore found in context'); return result!; } @override bool updateShouldNotify(ProductSelectionStore oldWidget) { return productAmounts != oldWidget.productAmounts; } }