Well, I am sort of new to Flutter, My question is why we use providers in Flutter, I know it is used for state management. But I am looking to know the most common use case of providers.
Provider is a wrapper around
InheritedWidget to make them easier to use and more reusable. this is probably the approach you should start with.
provider package is easy to understand and it doesn’t use much code. It also uses concepts that are applicable in every other approach.
By using provider instead of manually writing
InheritedWidget, you get:
- simplified allocation/disposal of resources
- a largely reduced boilerplate over making a new class every time
- devtools friendly
- a common way to consume these
- increased scalability for classes with a listening mechanism that grows exponentially in complexity (such as
ChangeNotifier, which is O(N²) for dispatching notifications).
See : Usage
This answer is given on the basis of : provider
Answered By – Paresh Mangukiya
Answer Checked By – Timothy Miller (FlutterFixes Admin)