The error “Bad state: Cannot add event after closing” indicates that the bloc has been closed and is no longer accepting events. Ensure that the bloc is still active when submitQuery is called. One way to fix this is by checking if the bloc is closed before calling submitQuery:
onChanged: (query) {
if (!bloc.isClosed) {
bloc.submitQuery(query);
}
},
This should prevent the error by ensuring events are only added when the bloc is active check here.