Getting a error during build this project

When i run this application and enter location then I got an error in my log cat which is " Bad state: Cannot add event after closing".

LocationScreen.build. (package:restaurant_finder/UI/location_screen.dart:58:44)

It indicates the code
onChanged: (query) => bloc.submitQuery(query),

in LocationScreen class.

So how i can fix this issue.

@pavel_android Do you still have issues with this?

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.