I'm developing with reactive components streams/observables with Rx_command, Rx_dart
Problem:
In my Flutter app I have inherited widget that can be called anywhere with:
FooProvider.of(context).foo.method1...
I need to make a first call to the method when the UI loads at first time
I use didchangedependencies it works but..
... every time the ui reloads, the didchangedependencies is called and the method is executed once again.
I don't want it to be executed and I can't use init.state
How can execute the method only once?
Instead of context.inheritFromWidgetOfExactType
, use context.ancestorInheritedElementForWidgetOfExactType
final myInherited = context.ancestorInheritedElementForWidgetOfExactType(MyInherited)?.widget;
This method is available inside initState
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With