flutter-quill
flutter-quill copied to clipboard
[Web] The provided text position is not in the current node
I have a filled QuillEditor
and I want to insert the image in the center. I select an empty row and click Align center
. Then I see this:
══╡ EXCEPTION CAUGHT BY FOUNDATION LIBRARY ╞════════════════════════════════════════════════════════
The following assertion was thrown while dispatching notifications for FocusNode:
Assertion failed:
file:///C:/Users/at/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_quill-7.1.10/lib/src/widgets/text_line.dart:1187:12
container.containsOffset(position.offset)
"The provided text position is not in the current node"
When the exception was thrown, this was the stack:
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw_
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3 assertFailed
packages/flutter_quill/src/widgets/text_line.dart 1187:45 globalToLocalPosition
packages/flutter_quill/src/widgets/editor.dart 1422:38 getLocalRectForCaret
packages/flutter_quill/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart 96:26 [_updateCaretRectIfNeeded]
packages/flutter_quill/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart 69:7 openConnectionIfNeeded
packages/flutter_quill/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart 40:7 openOrCloseConnection
packages/flutter_quill/src/widgets/raw_editor.dart 1231:5 [_handleFocusChanged]
packages/flutter/src/foundation/change_notifier.dart 381:24 notifyListeners
packages/flutter/src/widgets/focus_manager.dart 1038:5 [_notify]
packages/flutter/src/widgets/focus_manager.dart 1803:11 [_applyFocusChange]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15 <fn>
The FocusNode sending notification was:
FocusNode#24c1f([PRIMARY FOCUS])
════════════════════════════════════════════════════════════════════════════════════════════════════
@singerdmx , I am not sure if I can fix this without your help.
Here it is how it looks.
https://user-images.githubusercontent.com/45417992/233931062-4434b3f6-2091-4990-a2cb-e8da51d0f968.mp4
I'm getting the same on MacOS when ticking or unticking checkboxes in a checkboxed list. Although, it only seems to happen for the first checkboxed list item that is created in the text.
I also get the same issue on Android when undoing some text that was typed using swipe typing. It also happens sometimes when I undo several times having normally typed something.
@singerdmx any new about this issue? As I see you don't have enough time to fix this issue?
Any news?
Running into this exception as well. Happening when focus is restored to the editor after deleting the contents of the editor using the controller.
Did a little digging into what was going on in my situation and found that it seems when the document is altered by the controller in a way that makes the current selection position of the render editor no long actually be inside the same node. In my case the whole document went away so any position beyond 0 would result in this exception. I was able to fix the problem by adding the following to the RawEditorState
class initState
method in lib/src/widgets/raw_editor.dart
controller.onSelectionChanged = (textSelection) {
renderEditor.setSelection(textSelection);
};
Unfortunately it doesn't seem like this is a general fix as using these changes with the flutter-quill example app I'm still seeing the problem for the situations reported in this issue.
Did some more digging into this as I ran into this issue again when toggling a line from an unordered/ordered list back to plain text. The problem stems from accessing the editor state after it has been marked for rebuild (setState
). At that point the data in the editor widget is out of date relative to the controller. In some situations this is a problem as the structure of the document has changed; like when a line is changed into a list item by the toolbar.
I've submitted a possible fix for this with PR #1256
This should be fixed as of version 7.2.2
there is any solutions ?