When to use Provider.of vs. Consumer in Flutter

It doesn’t matter. But to explain things rapidly:

Provider.of is the only way to obtain and listen to an object.
Consumer, Selector, and all the *ProxyProvider calls Provider.of to work.

Provider.of vs Consumer is a matter of personal preference. But there’s a few arguments for both

Provider.of

  • can be called in all the widgets lifecycle, including click handlers and didChangeDependencies
  • doesn’t increase the indentation

Consumer

  • allows more granular widgets rebuilds
  • solves most BuildContext misuse

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)