As the last step for this class, add a dispose() method, in which you'll close the four StreamController objects. This may prevent memory leaks and errors that are difficult to debug:
//in the dispose method we need to close the stream controllers.
void dispose() {
_todosStreamController.close();
_todoInsertController.close();
_todoUpdateController.close();
_todoDeleteController.close();
}
The BLoC is now complete. The last step required is to implement the user interface in a way that will use the BLoC pattern to deal with the state in our app.