Skip to content

improves disposal function used in resetLazySingleton and unregister #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions lib/get_it_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1001,9 +1001,15 @@ class _GetItImplementation implements GetIt {

if (factoryToRemove.instance != null) {
if (disposingFunction != null) {
await disposingFunction.call(factoryToRemove.instance as T);
final dispose = disposingFunction.call(factoryToRemove.instance as T);
if (dispose is Future) {
await dispose;
}
} else {
await factoryToRemove.dispose();
final dispose = factoryToRemove.dispose();
if (dispose is Future) {
await dispose;
}
}
}
}
Expand Down Expand Up @@ -1036,9 +1042,15 @@ class _GetItImplementation implements GetIt {

if (instanceFactory.instance != null) {
if (disposingFunction != null) {
await disposingFunction.call(instanceFactory.instance as T);
final dispose = disposingFunction.call(instanceFactory.instance as T);
if (dispose is Future) {
await dispose;
}
} else {
await instanceFactory.dispose();
final dispose = instanceFactory.dispose();
if (dispose is Future) {
await dispose;
}
}
}

Expand Down
Loading