This takes us to our first question: where should we put the current
state of the cart?

Lifting state up

In Flutter,
it makes sense to keep the state above the widgets that use it.

Why? In declarative frameworks like Flutter, if you want to change the UI,
you have to rebuild it. There is no easy way to have
MyCart.updateWith(somethingNew). In other words, it’s hard to
imperatively change a widget from outside, by calling a method on it.
And even if you could make this work, you would be fighting the
framework instead of letting it help you.

// BAD: DO NOT DO THIS

void

myTapHandler

()

var

cartWidget

somehowGetMyCartWidget

();

cartWidget

updateWith

item

);