Skip to content

Conversation

@olorin99
Copy link
Contributor

@olorin99 olorin99 commented Dec 5, 2025

Add mounted checks in initState in case of instances when widget is scrolled out of view before async function returns.
Shouldn't need to add checks for setting state in button callbacks etc since its unlikely for the associated widget to be unmounted before the callback is completed.

Came across this after pressing 'Back to top' from far down on a feed. The quick scrolling resulted in a lot of null check operator errors.

@olorin99 olorin99 requested a review from jwr1 December 5, 2025 04:18
Copy link
Member

@jwr1 jwr1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I really wish Flutter didn't throw those kinds of errors. We shouldn't have to check if the widget is mounted every time we want to call setState (it should check automatically).

@jwr1 jwr1 merged commit 4924049 into main Dec 5, 2025
2 checks passed
@jwr1 jwr1 deleted the fix_null_state_access branch December 5, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants