Skip to content

Add optional ignoreIfNotRegistered to unregister #420 - #424

Open
AzazelSensei wants to merge 1 commit into
flutter-it:mainfrom
AzazelSensei:feat/unregister-ignore-if-not-registered
Open

Add optional ignoreIfNotRegistered to unregister #420#424
AzazelSensei wants to merge 1 commit into
flutter-it:mainfrom
AzazelSensei:feat/unregister-ignore-if-not-registered

Conversation

@AzazelSensei

Copy link
Copy Markdown

Widget dispose can run twice. unregister still throws by default so that still shows a double-dispose, but you can pass ignoreIfNotRegistered: true if the second call should just no-op.

getIt.unregister<MyService>(ignoreIfNotRegistered: true);

Fixes #420

Default still throws when the type or instance is missing.
Pass ignoreIfNotRegistered: true if a second dispose should no-op.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the unregister method ignore the non-existence of an instance instead of throwing an error.

1 participant