Flutter: Does it matter what code is in setState()?
When we want a StatefulWidget to rebuild we call setState() but does it really matter if the code we type is inside that function or outside of it? Is this: class _ShoppingListState extends State<ShoppingList> { Set<Product> _shoppingCart = new Set<Product>(); void _handleCartChanged(Product product, bool inCart) { setState(() { if (inCart) _shoppingCart.add(product); else _shoppingCart.remove(product); }); } } the same as this: class _ShoppingListState extends State<ShoppingList> { Set<Product> _shoppingCart = new Set<Product>(); void _handleCartChanged(Product product, bool inCart) { if