Skip to content

Fix hot reload when using the Watch widget #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davidmartos96
Copy link

Fixes #390

result.recompute(); in the addPostFrameCallback might get called with an invalid widget context on hot reload. I don't think this block is really needed, because didUpdateWidget is already taking into consideration the builder changing to properly update the "cached" widget signal.

I've tried and it seems to be working ok. Alternatively, if we want to keep the callback, we can add if (!mounted) return at the very beginning. This is the first thing I changed, but then I noticed that on hot reloads, the computed widget signal was being recomputed twice (one the callback and the other the didUpdateWidget), that's why I opted to kee the didUpdateWidget recompute only.

Also, I believe the didUpdateWidget needs to be a separate if statement, not if-else. Otherwise, we don't recompute if the dependencies list changes and the builder also changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant