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
{{ message }}
Repository navigation
Make the unregister method ignore the non-existence of an instance instead of throwing an error. #420
I'm developing an app, but I noticed that the dispose method of a widget is being called more than once, causing the second time to throw an error with the unregister method, which I think is unnecessary since it could easily be ignored.
That would be a possibility but in reality this shows you that you call dispose once too often.
If you cannot fix it add a guard value in your dispose function.
It's important that the library throws so you know that there is a logic problem
Am 25. Jan. 2026, 13:32 -0500 schrieb Gorniaky ***@***.***>:
Gorniaky created an issue (flutter-it/get_it#420)
I'm developing an app, but I noticed that the dispose method of a widget is being called more than once, causing the second time to throw an error with the unregister method, which I think is unnecessary since it could easily be ignored.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
I understand there's something wrong with the flow, but in production this only hinders progress. I simply put the function in a try-catch block because, to me, there's nothing wrong with my workflow, mainly because I register the dependency in initState and cancel it in dispose.
In short, my suggestion is to ignore the instance's non-existence.
That would be a possibility but in reality this shows you that you call dispose once too often.
If you cannot fix it add a guard value in your dispose function.
It's important that the library throws so you know that there is a logic problem
Am 25. Jan. 2026, 13:32 -0500 schrieb Gorniaky @.***>: …
Gorniaky created an issue (flutter-it/get_it#420)
I'm developing an app, but I noticed that the dispose method of a widget is being called more than once, causing the second time to throw an error with the unregister method, which I think is unnecessary since it could easily be ignored.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
Shipped in get_it 9.3.0 as a global flag: GetIt.I.skipUnregisterIfNotRegistered = true makes unregister a no-op for missing registrations (default still throws). See #424 for the reasoning behind the global flag.
Activity
escamoteur commentedon Jan 25, 2026
Gorniaky commentedon Jan 25, 2026
I understand there's something wrong with the flow, but in production this only hinders progress. I simply put the function in a try-catch block because, to me, there's nothing wrong with my workflow, mainly because I register the dependency in
initStateand cancel it indispose.In short, my suggestion is to ignore the instance's non-existence.
AzazelSensei commentedon Aug 13, 2026
Opened #424 — default still throws, optional ignoreIfNotRegistered if a second dispose should no-op.
Add skipUnregisterIfNotRegistered flag, acceptsParams, CONTRIBUTING.md
escamoteur commentedon Sep 19, 2026
Shipped in get_it 9.3.0 as a global flag:
GetIt.I.skipUnregisterIfNotRegistered = truemakesunregistera no-op for missing registrations (default still throws). See #424 for the reasoning behind the global flag.