fluttercommunity / get_it

Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur
https://pub.dev/packages/get_it
MIT License
1.36k stars 149 forks source link

[Question] - Auto-dispose Singleton when the widget's is unmounted from the widget tree #303

Closed dinbtechit closed 1 year ago

dinbtechit commented 1 year ago

Is it possible to automatically unregister a singleton when the widget is unmounted from the widget tree?

escamoteur commented 1 year ago

yep it is, with the get_it_mixin you can push a scope when a widget is first displayed and dispose the scope with its widgets when the widget is destroyed

dinbtechit commented 1 year ago

yep it is, with the get_it_mixin you can push a scope when a widget is first displayed and dispose the scope with its widgets when the widget is destroyed

Thank you @escamoteur !! Is there a code example of this?

escamoteur commented 1 year ago

it's in the readme.

dinbtechit commented 1 year ago

Perfect thank you!!! 🙏🙏🙏🙏