updateWith

item

);

Even if you get the above code to work,
you would then have to deal
with the following in the MyCart widget:

// BAD: DO NOT DO THIS

Widget

build

BuildContext

context

return

SomeWidget

// The initial state of the cart.

);

void

updateWith

Item

item

// Somehow you need to change the UI from here.

You would need to take into consideration the current state of the UI
and apply the new data to it. It’s hard to avoid bugs this way.