Skip to content
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

Watch isn't checking for mounted in post frame callback. #338

Closed
RsMan-Dev opened this issue Nov 19, 2024 · 1 comment · Fixed by #331
Closed

Watch isn't checking for mounted in post frame callback. #338

RsMan-Dev opened this issue Nov 19, 2024 · 1 comment · Fixed by #331
Labels
question Further information is requested

Comments

@RsMan-Dev
Copy link

Hi! i faced a problem in flutter today. your Watch uses a post frame callback, this is not an issue in majority of cases, but i'm using a context that is building my page twice in one frame, the first one get instantly disposed (actually an issue, but not necessarily one in other projects). so when my render finishes, watch calls an update on disposed widgets.

i made my own class to wait:
this.createComputed(() => widget.builder(context),
debugLabel: widget.debugLabel)
became:
this.createComputed(() => mounted ? widget.builder(context) : Container(),
debugLabel: widget.debugLabel)

and
WidgetsBinding.instance.addPostFrameCallback(() {
result.recompute();
if (mounted) setState(() {});
});
became
WidgetsBinding.instance.addPostFrameCallback((
) {
if (mounted) result.recompute();
if (mounted) setState(() {});
});

@rodydavis
Copy link
Owner

rodydavis commented Nov 19, 2024

Can you test on v6? It should be fixed.

Also please share a minimal code sample to reproduce as that is something we definitely want to test for.

@rodydavis rodydavis added the question Further information is requested label Nov 21, 2024
@rodydavis rodydavis linked a pull request Nov 28, 2024 that will close this issue
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants