Widget _buildCart(BuildContext context, Widget child) { AppStateModel model = ScopedModel <AppStateModel> .of(context); int numProducts = model.productsInCart.Keys.Count; int totalCartQuantity = model.totalCartQuantity; Size screenSize = MediaQuery.of(context).size; float screenWidth = screenSize.width; float screenHeight = screenSize.height; _width = _widthFor(numProducts); _widthAnimation = _getWidthAnimation(screenWidth); _heightAnimation = _getHeightAnimation(screenHeight); _shapeAnimation = _getShapeAnimation(); _thumbnailOpacityAnimation = _getThumbnailOpacityAnimation(); _cartOpacityAnimation = _getCartOpacityAnimation(); return(new Container( width: _widthAnimation.value, height: _heightAnimation.value, child: new Material( animationDuration: TimeSpan.FromMilliseconds(0), shape: new BeveledRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(_shapeAnimation.value) ) ), elevation: 4.0f, color: shrineColorsUtils.kShrinePink50, child: _cartIsVisible ? _buildShoppingCartPage() : _buildThumbnails(numProducts) ) )); }
Product _productWithId(int productId) { AppStateModel model = ScopedModel <AppStateModel> .of(context); Product product = model.getProductById(productId); D.assert(product != null); return(product); }
public override void initState() { base.initState(); _list = new _ListModel( listKey: _listKey, initialItems: ScopedModel <AppStateModel> .of(context).productsInCart.Keys.ToList(), removedItemBuilder: _buildRemovedThumbnail ); _internalList = new List <int>(_list.list); }
void _updateLists() { _internalList = ScopedModel <AppStateModel> .of(context).productsInCart.Keys.ToList(); HashSet <int> internalSet = new HashSet <int>(_internalList); HashSet <int> listSet = new HashSet <int>(_list.list); HashSet <int> difference = new HashSet <int>(); foreach (var _set in internalSet) { if (!listSet.Contains(_set)) { difference.Add(_set); } } if (difference.isEmpty()) { return; } foreach (int product in difference) { if (_internalList.Count < _list.length) { _list.remove(product); } else if (_internalList.Count > _list.length) { _list.add(product); } } while (_internalList.Count != _list.length) { int index = 0; // Check bounds and that the list elements are the same while (_internalList.isNotEmpty() && _list.length > 0 && index < _internalList.Count && index < _list.length && _internalList[index] == _list.ElementAt(index)) { index++; } } }