Closed rohit-suthar closed 6 months ago
Possible fix:
Stream
instead of Future
because it is cancellable.status
prop in your State and check if the current state is loading to prevent the user to quickly navigate away from the current screen. You can check whether bloc is closed using isClosed
. A lot of people wrap this check and emit within a safeEmit
function like this https://github.com/felangel/bloc/issues/3069#issuecomment-1095547362
Description In our project, we are encountering numerous Firebase crashes associated with this error: "Bad state: Cannot emit new states after calling close."
A very common scenario for reproducing this issue is when a user presses the back button on the screen, and we have initiated an API call on that screen. We emit a new state upon the success of the API, but as the user already navigated back and the bloc is disposed, this error occures.