Skip to content

fix: Auto-scroll crashes when target unmounts mid-scroll β€” re-check mounted after await - #664

Open
Fellmonkey wants to merge 1 commit into
SimformSolutionsPvtLtd:fix/issue_659_null_check_error_on_register_state_disposedfrom
Fellmonkey:fix/autoscroll-unmounted-context
Open

Fellmonkey wants to merge 1 commit into
SimformSolutionsPvtLtd:fix/issue_659_null_check_error_on_register_state_disposedfrom
Fellmonkey:fix/autoscroll-unmounted-context

Conversation

@Fellmonkey

Copy link
Copy Markdown

Description

scrollIntoView() only checked _mounted before
await Scrollable.ensureVisible(_context). After the await,
_waitForScrollToSettle() read _context without re-checking mounted, so a
target that unmounted during the scroll (e.g. the page rebuilt after async
data arrived) crashed with:

This widget has been unmounted, so the State no longer has a context

This PR re-checks _mounted after each await and bails out of the scroll
instead of touching the defunct context.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #662 (also relates to the earlier #313)

Note: test/, docs and examples stays unchecked β€” this repo has no
test suite yet, and the fix touches private methods only (no doc API), so
no dartdoc/examples change applies.

@apurva010
apurva010 force-pushed the fix/autoscroll-unmounted-context branch from 4844606 to c3c15b7 Compare September 10, 2026 11:00
@apurva010
apurva010 changed the base branch from master to fix/issue_659_null_check_error_on_register_state_disposed September 10, 2026 11:01
@apurva010
apurva010 force-pushed the fix/autoscroll-unmounted-context branch from c3c15b7 to 7d57617 Compare September 10, 2026 11:02
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.

scrollIntoView() crashes when the target unmounts during the async auto-scroll

1 participant