Bloc: Event reaches mapEventToState but nothing happens afterwards

Created on 3 Oct 2020  路  2Comments  路  Source: felangel/bloc

Describe the bug
I am having an issue with a bloc I implemented. The widget triggers the event when a button is tapped and the event reaches mapEventToState but no state is emitted and nothing happens on the UI. Also, if I observe it in the onChange() method, I see nothing. It only happens once.

To Reproduce
This is the project and branch in which I implement the bloc pattern: https://github.com/flutter-clutter/flutter-basic-calculator/tree/bloc. You can check it out and start. The first time a button is tapped, a output can be seen but any subsequent action is not logged.

What am I missing?

question

Most helpful comment

Hey @felangel.
Oh, it seems I was running into a common issue. Should have read the FAQ. You are right this issue was because I was re-using the model instead of creating a completely new one. Thank you for your quick response.

All 2 comments

Hi @flutter-clutter 馃憢
Thanks for opening an issue!

Have you taken a look at the FAQs? It looks like the issue is the CalculationModel is not extending Equatable and the bloc is mutating the model instead of creating a new instance.

Hey @felangel.
Oh, it seems I was running into a common issue. Should have read the FAQ. You are right this issue was because I was re-using the model instead of creating a completely new one. Thank you for your quick response.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MahdiPishguy picture MahdiPishguy  路  3Comments

hivesey picture hivesey  路  3Comments

nhwilly picture nhwilly  路  3Comments

Reidond picture Reidond  路  3Comments

abinvp picture abinvp  路  3Comments