AppFlowy-IO / AppFlowy-IO/appflowy-editor

[Bug] ValueNotifier disposed exception when reopening page with shrinkWrap=true EditorScrollController

Aperta
#1,151 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Dart
Stelle
684
Fork
329
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Bug Description

When using AppFlowyEditor with EditorScrollController(shrinkWrap: true) and reusing the same EditorState instance, the app throws a “ValueNotifier was used after being disposed” exception after navigating away and reopening the page.

This happens because EditorScrollController adds a listener to editorState.document.root when shrinkWrap is enabled, but never removes it in dispose().
When the editor is rebuilt or reopened, the stale listener still tries to update the disposed visibleRangeNotifier or offsetNotifier, causing the crash.

### How to Reproduce

Create an editor page that uses a persistent EditorState:

final editorState = EditorState.blank(withInitialText: true);

Inside your page, use:

AppFlowyEditor(
editorState: editorState,
shrinkWrap: true,
)

Navigate away from the page (so the widget and controller are disposed).

Navigate back to the same page using the same editorState.

Try typing or editing text — the exception appears:

A ValueNotifier was used after being disposed.

### Expected Behavior

The editor should work normally when reopened, even when reusing the same EditorState.
No exceptions should occur from disposed notifiers or stale listeners.

### Operating System

IOS, Android

### AppFlowy Editor Version(s)

5.2.0

### Screenshots

_No response_

### Additional Context

_No response_

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.