Skip to content

Commit 4a97a09

Browse files
authored
Remove last mention of Model (#2691)
Also make the code correspond to the gif by assigning each item a price of $42 (instead of $1).
1 parent 4ad95b4 commit 4a97a09

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

examples/state_mgmt/simple/lib/src/provider.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ class CartModel extends ChangeNotifier {
1616
/// An unmodifiable view of the items in the cart.
1717
UnmodifiableListView<Item> get items => UnmodifiableListView(_items);
1818

19-
/// The current total price of all items (assuming all items cost $1).
20-
int get totalPrice => _items.length;
19+
/// The current total price of all items (assuming all items cost $42).
20+
int get totalPrice => _items.length * 42;
2121

2222
/// Adds [item] to cart. This is the only way to modify the cart from outside.
2323
void add(Item item) {
2424
_items.add(item);
25-
// This call tells [Model] that it should rebuild the widgets that
26-
// depend on it.
25+
// This call tells the widgets that are listening to this model to rebuild.
2726
notifyListeners();
2827
}
2928
}

src/docs/development/data-and-backend/state-mgmt/simple.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,13 @@ class CartModel extends [!ChangeNotifier!] {
217217
/// An unmodifiable view of the items in the cart.
218218
UnmodifiableListView<Item> get items => UnmodifiableListView(_items);
219219
220-
/// The current total price of all items (assuming all items cost $1).
221-
int get totalPrice => _items.length;
220+
/// The current total price of all items (assuming all items cost $42).
221+
int get totalPrice => _items.length * 42;
222222
223223
/// Adds [item] to cart. This is the only way to modify the cart from outside.
224224
void add(Item item) {
225225
_items.add(item);
226-
// This call tells [Model] that it should rebuild the widgets that
227-
// depend on it.
226+
// This call tells the widgets that are listening to this model to rebuild.
228227
[!notifyListeners!]();
229228
}
230229
}

0 commit comments

Comments
 (0)