flutter: Unhandled Exception: Bad state: Cannot add new events after calling close

后端 未结 6 885
清酒与你
清酒与你 2021-01-01 12:01

I am trying to use the bloc pattern to manage data from an API and show them in my widget. I am able to fetch data from API and process it and show it, but I am using a bott

6条回答
  •  天命终不由人
    2021-01-01 12:51

    I run into same error and noticed that if you check isClosed, the screen is not updated. In your code you have to remove the last line from Bloc file:

    ServiceBloc serviceBloc = new ServiceBloc();
    

    and put this line in CategoryPage just before the initState(). This way your widget is creating and disposing the bloc. Before, the widget only disposes the bloc but it is never re-created when the widget is re-created.

提交回复
热议问题