brianegan/flutter_redux

Builder is called even when state is not changed

guyo13 opened this issue · 1 comments

I am working on an app where I use StoreConnectors heavily, I started noticing that the builder callback is being called - sometimes more than once - even if I don't make any changes to the state.
This happens when I for example open/close a Drawer or change focus between TextFields.

All my StoreConnectors are set to distinct=true and view models correctly implement operator == and hashCode
and really if the vms don't change then onDidChange is not fired.

I just don't understand why all those StoreConnectors keep firing their builders on every small user interaction.

Would be appreciated if anyone can help me understand why is this happening

Heya @guyo13 -- When you open or close a drawer, Flutter is pushing a new route to the Navigator. This also causes most Widgets to rebuild -- so that's nothing to worry about.

On the other hand, if you're seeing your StoreConnectors rebuilding whenever you change focus, that sounds like a bug either in your app or Flutter Redux. However, I have tests in place specifically to verify Connectors only rebuild when they should, not on any little interaction, and I haven't seen that behavior in my own apps.

Do you happen to have a small sample that reproduces the error?