Why Use the Provider?

As you may have noticed, I frequently used setState() in earlier tutorials. Now that setState() has been called, the framework will be informed that the internal state of the object has changed, which essentially implies that the object will be rebuilt with the new values. SetState() has the drawback of building both the parent widget and every child widget, regardless of whether they are StatefulWidgets or StatelessWidgets. The failure of setState() to aid in the separation of concerns, or more specifically, the division of your code into layers, is another issue (presentation, domain, data).

There are several various state management programs to address the aforementioned problems, and Remi Rousselet’s provider is one of them. In plain language provider is a wrapper around Inherited Widgets, which was explained in the previous tutorial Using Inherited Widgets In Flutter.