escamoteur / watch_it

MIT License
103 stars 8 forks source link

Document WatchingStatefulWidget and WatchingStatefulWidgetMixin #24

Closed exaby73 closed 5 months ago

exaby73 commented 6 months ago

I noticed in the docs that there is no use of StatefulWidgets, which makes sense. So without access to initState, how do I run code only once on first build?

More broadly, are there any plans to support lifecycle hooks, like initState, dispose, etc.?

Side note: I usually use flutter_hooks for this, with an empty dependency array passed to useEffect but seems watch_it is not compatible with HookWidget

Edit: I see that there are widgets and mixins for StatefulWidget as well. Maybe this should be documented. While this solves my issue, I think I'll keep this issue open for discussion on docs. Thanks

escamoteur commented 6 months ago

Indeed, there is a mixin for StatefulWidgets and a WatchingStatefulWidget see https://github.com/escamoteur/watch_it#the-watchingwidgets but I agree that I could add a sentence of using the WatchItStatefulWidget

escamoteur commented 6 months ago

Btw I'm thinking ob adding an executeOnce function

exaby73 commented 5 months ago

executeOnce would be really good. It would help with eliminating the need for StatefulWidgets altogether