You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I wanna listening to MyState.needRefresh change and re-fetch the data whatever which page is showing.
It works fine in build() except at least called once, so I move them in to initState(), here comes the error
flutter: 'package:provider/src/provider.dart': Failed assertion: line 274 pos 7: 'context.owner!.debugBuilding || listen == false || debugIsInInheritedProviderUpdate': Tried to listen to a value exposed with provider, from outside of the widget tree.
This is likely caused by an event handler (like a button's onPressed) that calledProvider.of without passing `listen: false`.To fix, write:Provider.of<MyState>(context, listen: false);It is unsupported because may pointlessly rebuild the widget associated to theevent handler, when the widget tree doesn't care about the value.
Please tell me how can I fix this.
The text was updated successfully, but these errors were encountered:
Describe the bug
Cannot use
context.watch()
in initStateTo Reproduce
Expected behavior
I have several pages which showing different type data
So I wanna listening to
MyState.needRefresh
change and re-fetch the data whatever which page is showing.It works fine in
build()
except at least called once, so I move them in toinitState()
, here comes the errorPlease tell me how can I fix this.
The text was updated successfully, but these errors were encountered: