Example #1
0
        Product _productWithId(int productId)
        {
            AppStateModel model = ScopedModel <AppStateModel> .of(context);

            Product product = model.getProductById(productId);

            D.assert(product != null);
            return(product);
        }
Example #2
0
        List <Widget> _createShoppingCartRows(AppStateModel model)
        {
            List <Widget> widgets = new List <Widget>();

            foreach (var product in model.productsInCart.Keys)
            {
                int id = product;
                widgets.Add(new ShoppingCartRow(
                                product: model.getProductById(id),
                                quantity: model.productsInCart[id],
                                onPressed: () => {
                    model.removeItemFromCart(id);
                }
                                ));
            }

            return(widgets);
        }