Skip to content

Proposed fix for issue where closeConnectionIfNeeded() was initiating a _markNeedsBuild() during dispose, causing exception #2595

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: master
Choose a base branch
from

Conversation

woodyhayday
Copy link

@woodyhayday woodyhayday commented Jun 13, 2025

Proposed fix for issue where closeConnectionIfNeeded() was initiating a _markNeedsBuild() during dispose, causing exception

Using flutter_quill 11.4.1 I was hitting this error in my flutter app, where by:

  1. Load a widget with Quill (whole screen editor, with back button)
  2. User hits back button.
  3. App copies text out of Quill.
  4. App changes page (setPageIndex), which disposes the Quill widget.
  5. Quill's dispose() fires closeConnectionIfNeeded()
  6. Which changes RawEditorStateTextInputClientMixin._lastKnownRemoteTextEditingValue
  7. Which notifies QuillRawEditorState._onComposingRangeChanged()
  8. Which fires _markNeedsBuild() because mounted = true still

I'm an experienced engineer outside of dart, but I've been dabbling here for a few months. This may be the way my own app is setup, bungling the process, but I dug through this for a few hours and this PR was my best attempt at a fix today.

Here's the error stack:

Screenshot 2025-06-13 at 13 11 28

PR Description

Reorders dispose() actions, making sure composingRange.removeListener(_onComposingRangeChanged); fires before closeConnectionIfNeeded() to avoid the latter firing the former and leading to an exception.

Type of Change

  • 🛠️ Bug fix: Resolves an issue without changing current behavior.

… a _markNeedsBuild() during dispose, causing exception
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.

1 participant