singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.53k stars 809 forks source link

Assertion Failure in line.dart When Editing Text with Block-Level Attributes in Debug Mode #2150

Closed Gabianne01 closed 1 week ago

Gabianne01 commented 2 weeks ago

Is there an existing issue for this?

Flutter Quill version

10.4.5

Steps to reproduce

  1. Create a text using the Flutter Quill editor.
  2. Apply a block-level attribute (e.g., list, alignment).
  3. Delete a character in the text.
  4. Continue typing.
  5. Observe that the new text does not appear until the editor loses focus.

Expected results

Text should appear immediately when typed, without requiring the editor to lose focus. No assertion failures should occur.

Actual results

In debug mode, the text does not appear until the editor loses focus. An assertion failure occurs in line.dart on line 147.

Code sample

No response

Additional Context

I've encountered an assertion failure when using the Flutter Quill editor in debug mode. This issue occurs specifically when I apply block-level attributes (such as lists or alignment) to text, delete a character, and then attempt to type again. The issue manifests as follows:

Behavior in Debug Mode:

After deleting a character, any further typing does not immediately appear in the editor. The typed text only becomes visible after the editor loses focus. The following assertion is thrown:

Behavior in Release Mode:

The issue does not occur in release mode. The editor behaves as expected, with no assertion failure or delayed text rendering.

The issue might be related to https://github.com/singerdmx/flutter-quill/issues/1622

Logs ```console Exception caught by services library The following assertion was thrown during method call TextInputClient.updateEditingState: 'package:flutter_quill/src/document/nodes/line.dart': Failed assertion: line 147 pos 14: 'style.values.every((attr) => attr.scope == AttributeScope.inline || attr.scope == AttributeScope.ignore)': is not true. ```
AtlasAutocode commented 2 weeks ago

The assertion is bringing our attention to a fault in the logic. Simply removing the assert, or using release mode, is not the correct solution as it corrupts the quill deltas and is likely to cause other problems at a later time.

The fault is in the caller, but I have not found the root cause yet.