Understand how listen: false works when used with Provider<SomeType>.of(context, listen: false)
That's because, while the widget that called Provider.of
with listen:false
did not want to rebuild, its parent forced it to.
In your example, when Counter
changes, MyHomePage
rebuilds and recreate the widget that specified listen:false
, which in turn force it to rebuild too.
MyHomePage
should specify listen: false
too here.