Instead:

Provider.of

Sometimes, you don’t really need the data in the model to change the
UI but you still need to access it. For example, a ClearCart
button wants to allow the user to remove everything from the cart.
It doesn’t need to display the contents of the cart,
it just needs to call the clear() method.

We could use Consumer<CartModel> for this,
but that would be wasteful. We’d be asking the framework to
rebuild a widget that doesn’t need to be rebuilt.

For this use case, we can use Provider.of,
with the listen parameter set to false.

listen: false).removeAll();

Using the above line in a build method won’t cause this widget to
rebuild when notifyListeners is called.

Putting it all together