Combining Riverpod and Provider
Understand how to combine Riverpod and the older Provider package for effective state management in Flutter. Explore methods to watch and update state with minimal widget rebuilds, using ScopedReader and Consumer widgets. Gain practical insights into reducing boilerplate code and optimizing widget performance in your cross-platform Flutter apps.
We'll cover the following...
Watching Provider objects in Riverpod
We can watch it by using the Consumer builder like the following code snippet:
In the above code, this part holds the trick:
We’ll show a more straightforward method in this section. That will drastically reduce the boilerplate code. However, the above method reduces the widget rebuilds more than any other method. Here the Text widget is the only widget rebuilt.
In the following code snippet, we can see how the ...