The-ring-io / flutter_phoenix

Easily restart your application from scratch.
MIT License
153 stars 17 forks source link

Add two optional callbacks #4

Closed caneva20 closed 3 years ago

caneva20 commented 4 years ago

Hello @MrLepage.

This PR adds two callbacks that can be used as a sort of life cycle hook, a setup that is called when the starts or is restarted, and another one that is called just before "resetting" the app. I've added those because my app needs those hooks and I thought it would be a good addition to the plugin. I've also updated the README to explain a bit how to use them.

Feel free to ask for any changes if you judge necessary, or to reject it.

nt4f04uNd commented 3 years ago

how are these callbacks different from initState and dispose of the App?

MrLepage commented 3 years ago

Same question as @nt4f04uNd.

This is not the responsibility of the Phoenix widget to init or dispose your App.

You can use initState and dispose method of your App for this.

caneva20 commented 3 years ago

Hmm... It seems I was overthinking when I proposed this. I now see that this doesn't make sense. At the time I had Phoenix wrapping a MaterialApp without a direct child (using routes only). In this scenario I couldn't use MaterialApp to do setup/disposed, but I didn't realize I could just wrap MaterialApp with another widget and achieve the same thing this PR "solves". It was just dumb of me submitting this, should've thought further.

Sorry :)