Understanding Providers.

Shakya Prabin
2 min readJul 9, 2021

--

Providers are completely new things for anyone switching to Flutter from Native mobile apps development. There are lots and lots of articles written on it. In this article I have shared my knowledge on one of the type of Provider, that is “ProxyProvider”. This article is requires your understanding of Dart, State Management in Flutter, “Provider” Package, ChangeNotifier and so on. So this is definitely not for beginners.

  1. •Class Name: “HOUSE” => Is ChangeNotifier
  2. •Class Name: “BALCONY” => Is not ChangeNotifier
  3. “HOUSE” is dependency injected to “BALCONY”.
  4. ProxyProvider is used to inject this dependency.
  5. Now there are two ways we can use ProxyProvider.
  6. ProxyProvider has one main method to be careful of. It is “Update” method.
  7. So main magic happens in this “Update” method.
  8. “Update” method determines how to react to the change in injected dependency.

a) Using “Update” Method First way:

b) Using “Update” Method Second way:

c) Invoked “Update” Method inside the Proxy class (“Balcony” here).

I hope above code will be useful and help you understand “ProxyProvider”.

--

--

Shakya Prabin

Freelance Mobile Apps Developer/ Senior iOS Developer / Game Developer/ Traveler / IT Consultant