-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat: method for safe emission of new states #3403
Comments
It's complicated for BLoC since You could just use extensions methods:
Usage:
For cubit:
Usage:
For Cubit you also could use mixins. |
This is indeed a common case people talk about often. Similarly, in Flutter, you can see It is hard to say whether some way of While it makes sense, it can hide potential errors, like making We could suppress it directly in the |
The |
Closing this since it's a duplicate of #4165 |
Description
In personal and work projects, we use a lot a method that we basically copy-paste for every Bloc/Cubit. This is it:
This avoids new states to be emitted after closing the Bloc, so the Bad state error doesn't get thrown.
Desired Solution
Ideally, add the safeEmit function to the BlocBase class.
The text was updated successfully, but these errors were encountered: