Skip to content
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

Close instances of dart.core.Sink. warning by IDE #1942

Closed
momoDragon opened this issue Nov 18, 2020 · 3 comments
Closed

Close instances of dart.core.Sink. warning by IDE #1942

momoDragon opened this issue Nov 18, 2020 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@momoDragon
Copy link

Documentation
Screenshot 2020-11-18 at 5 44 48 PM

My implementation
Screenshot 2020-11-18 at 5 44 37 PM

Got a warning by my IDE saying
Close instances of dart.core.Sink``

The implementation should be correct based on the docs but there is waring.
Is the code violating anything? and if not, is there any plans to refactor to get rid of the warning?

Cheers

@ritik-playground
Copy link

In this way, you're manually accessing your bloc. To solve this, dispose your provider by calling customerBloc?.close() in your dispose().

@felangel
Copy link
Owner

@momoDragon what you’re doing is perfectly fine and the warning is a false positive from the dart linter. There’s an open issue for this but in the meantime you can disable close_sinks in your analysis_options.yaml. You shouldn’t need to call close because BlocProvider does that for you.

See #587 for more details.

@felangel felangel self-assigned this Nov 18, 2020
@felangel felangel added the question Further information is requested label Nov 18, 2020
@momoDragon
Copy link
Author

momoDragon commented Nov 19, 2020

Thanks for the info @felangel

I found that getting state just once this would be ideal for my case.
CustomerState customerState = BlocProvider.of<CustomerBloc>(context).state;

@shaan-saz Calling .close() actually closes my bloc. so to get the bloc once and close it was not wise in my case.

Anyway thanks for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants