Consumer
Learn about the Consumer widget from the provider package.
We'll cover the following...
Problem with the provider
We’ve seen how to use the provider and how it behaves. But there is a little problem with how we use the provider to rebuild the UI. When we write the following line of code, it will listen to the change in the provider (CounterProvider
) and call the build()
method again, which essentially rebuilds the whole UI.
CounterProvider counterProvider =
Provider.of<CounterProvider>(context, listen: true);
However, this is not the most efficient way. We want to avoid rebuilding the whole UI since ...