flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

The following assertion was thrown during method call TextInputClient.updateEditingState

Open MacDeveloper1 opened this issue 1 year ago • 2 comments

This error is occurred when press Enter key in text editor.

══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞═════════════════════════════════════════════
The following assertion was thrown during method call TextInputClient.updateEditingState:
Assertion failed:
file:///C:/Users/at/AppData/Local/Pub/Cache/git/flutter-quill-9.0.3/lib/src/models/rules/insert.dart:62:14
after.isPlain
is not true

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:3                         throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 35:3                          assertFailed
packages/flutter_quill/src/models/rules/insert.dart 62:19                                           applyRule
packages/flutter_quill/src/models/rules/rule.dart 24:12                                             apply
packages/flutter_quill/src/models/rules/rule.dart 94:28                                             apply
packages/flutter_quill/src/models/documents/document.dart 87:26                                     insert
packages/flutter_quill/src/models/documents/document.dart 127:15                                    replace
packages/flutter_quill/src/widgets/quill/quill_controller.dart 295:24                               replaceText
packages/flutter_quill/src/widgets/raw_editor/raw_editor_state_text_input_client_mixin.dart 204:29  updateEditingValue
packages/flutter/src/services/text_input.dart 2025:15                                               [_updateEditingValue]
packages/flutter/src/services/text_input.dart 1858:19                                               _handleTextInputInvocation
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                                  runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                                  _async
packages/flutter/src/services/text_input.dart 1774:45                                               [_handleTextInputInvocation]
packages/flutter/src/services/text_input.dart 1759:20                                               _loudlyHandleTextInputInvocation
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                                  runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                                  _async
packages/flutter/src/services/text_input.dart 1757:51                                               [_loudlyHandleTextInputInvocation]
packages/flutter/src/services/platform_channel.dart 559:55                                          _handleAsMethodCall
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                                  runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                                  _async
packages/flutter/src/services/platform_channel.dart 556:40                                          [_handleAsMethodCall]
packages/flutter/src/services/platform_channel.dart 552:34                                          <fn>
packages/flutter/src/services/binding.dart 567:35                                                   <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                                  runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                                  _async
packages/flutter/src/services/binding.dart 564:98                                                   <fn>
lib/_engine/engine/platform_dispatcher.dart 1305:5                                                  invoke2
lib/ui/channel_buffers.dart 25:12                                                                   invoke
lib/ui/channel_buffers.dart 65:7                                                                    push
lib/ui/channel_buffers.dart 131:16                                                                  push
lib/_engine/engine/platform_dispatcher.dart 408:10                                                  invokeOnPlatformMessage
lib/_engine/engine/text_editing/text_editing.dart 2183:30                                           updateEditingState
lib/_engine/engine/text_editing/text_editing.dart 2306:11                                           <fn>
lib/_engine/engine/text_editing/text_editing.dart 1391:7                                            handleChange
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 574:37                    _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 579:39                    dcall

call:
  MethodCall(TextInputClient.updateEditingState, [5, {text: This standard classifies the resistance
  of windows, doors, shutters, and grilles against burglary into various resistance classes. These
  classes offer different levels of protection against attacks by different methods. These
  resistance classes take into consideration various factors including the strength of the
  components, the quality of the locks and hardware, and the resistance to mechanical and human
  impacts. The testing
  methods to certify these classes include static and dynamic loading tests, as well as manual
  burglary attempts with specified tools based on the respective class.
  , selectionBase: 431, selectionExtent: 431, composingBase: -1, composingExtent: -1}])
═══════════════════════════════════════════════════════════════════════════════

MacDeveloper1 avatar Dec 19 '23 12:12 MacDeveloper1

Can you tell me how to reproduce the bug if you know? or at least what last thing you did

In either case, That's quite an old bug, I'm afraid I can't fix it, @singerdmx Can you take a look?

EchoEllet avatar Dec 19 '23 13:12 EchoEllet

After investigation code I noticed that there is an assert which means that the after operation must be plain, i.e. must not contains attributes.

final delta = Delta()..retain(index + (len ?? 0));
if (after.data is String && (after.data as String).contains('\n')) {
  assert(after.isPlain);                                      // <-----------------------------
  delta.insert('\n');
  return delta;
}

But in my case the Delta contains similar data

[
  "insert": {
    "Some text",
    "attributes": {
      "font": "Roboto",
      "size": 14
    }
  },
]

So when I set focus on Quill editor inside of the entered text and press Enter key, i.e. create a new line then I get the assert activation. Is really assert required?

MacDeveloper1 avatar Dec 21 '23 12:12 MacDeveloper1