Skip to content

[bug] offset >= -1 is not true error #170

Description

@npateras

Steps to reproduce: I have a textfield that has this inputFormatters:

inputFormatters: [MaskedInputFormatter('00/00/0000')]

Trying to type and then deleting the text to empty it from the textfield gives this error:

======== Exception caught by widgets ===============================================================
The following assertion was thrown while applying input formatters:
Assertion failed: org-dartlang-sdk:///lib/ui/text.dart:592:16
offset >= -1
is not true

When the exception was thrown, this was the stack: 
../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3       throw_
../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3        assertFailed
../lib/ui/text.dart 592:27                                                           collapsed
../packages/flutter/src/services/text_editing.dart 36:14                             collapsed
../packages/flutter_multi_formatter/formatters/masked_input_formatter.dart 122:32    formatEditUpdate
../packages/flutter/src/widgets/editable_text.dart 4150:81                           <fn>
../dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 263:22                fold]
../packages/flutter/src/widgets/editable_text.dart 4148:41                           [_formatAndSetValue]
../packages/flutter/src/widgets/editable_text.dart 3224:7                            updateEditingValue
../packages/flutter/src/services/text_input.dart 2061:15                             [_updateEditingValue]
../packages/flutter/src/services/text_input.dart 1894: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 1809:45                             [_handleTextInputInvocation]
../packages/flutter/src/services/text_input.dart 1794: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 1792:51                             [_loudlyHandleTextInputInvocation]
../packages/flutter/src/services/platform_channel.dart 571: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 568:40                        [_handleAsMethodCall]
../packages/flutter/src/services/platform_channel.dart 564:34                        <fn>
../packages/flutter/src/services/binding.dart 581: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 578:98                                 <fn>
../lib/_engine/engine/platform_dispatcher.dart 1438:7                                <fn>
../dart-sdk/lib/async/zone.dart 1399:13                                              _rootRun
../dart-sdk/lib/async/zone.dart 1301:19                                              run
../dart-sdk/lib/async/zone.dart 1209:7                                               runGuarded
../lib/_engine/engine/platform_dispatcher.dart 1437:9                                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 468:10                                invokeOnPlatformMessage
../lib/_engine/engine/text_editing/text_editing.dart 2202:30                         updateEditingState
../lib/_engine/engine/text_editing/text_editing.dart 2325:11                         <fn>
../lib/_engine/engine/text_editing/text_editing.dart 1410:7                          handleChange
../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 426:37  _checkAndCall
../dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 431:39  dcall
====================================================================================================

It's not consistent but I can reproduce simply like this:

TextField(
     inputFormatters: [MaskedInputFormatter('00/00/0000')],
),

Flutter version: 3.22.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions