Skip to content
New issue

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

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

Already on GitHub? # to your account

dispose function passed to registerSingleton not called #138

Closed
mbnadjib opened this issue Dec 8, 2020 · 3 comments
Closed

dispose function passed to registerSingleton not called #138

mbnadjib opened this issue Dec 8, 2020 · 3 comments

Comments

@mbnadjib
Copy link

mbnadjib commented Dec 8, 2020

GetIt version: 5.0.1
Code example:

class Product {
  Product() {
    print('new instance of Product');
  }
}

void main() {
  GetIt.I.registerSingleton<Product>(Product(), dispose: (p) {
    print('$p disposed'); /// <== this is never called
  });
  GetIt.I.unregister<Product>();
}

Behavior: dispose is not called
Expected behavior: dispose should be called on unregister

Am i missing something ?

@escamoteur
Copy link
Collaborator

I would say you might have found a bug. let me check

@escamoteur
Copy link
Collaborator

fixed in V5.0.2

@alsoLut
Copy link

alsoLut commented Apr 11, 2021

I'm seeing this problem again in '6.0.0'

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants