I\'m still wrapping my head around state-management techniques in flutter and am a bit confused about when and why to use Provider.of
vs. Consume
For your questions:
Provider.of
and Consumer
. Former doesn't update UI, latter does?Provider.of
depends on value of listen
to trigger a new State.build
to widgets and State.didChangeDependencies
for StatefulWidget
.
Consumer
always update UI, as it uses Provider.of
, where listen
is true
. See full source here.
listen
isn't set to false
will the widget be rebuilt by default or not rebuilt? What if listen
is set to true
?Default value is true
, means will trigger a new State.build
to widgets and State.didChangeDependencies
for StatefulWidget
. See full source here.
static T of
.
Provider.of
with the option to rebuild the UI at all when we have Consumer
?Pretty much covered by Rémi Rousselet's answer.