Skip to content

Pressing shiftkey to insert ( or ) in textfield crashes flutter application #108646

@n7484443

Description

@n7484443

After upgrading flutter version from 3.1.0-9.0.pre to 3.3.0-0.1.pre, this bug appeared.
I am using windows 11

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. press left Shift Key a little
  3. press 9 to input '('
  4. press left Shift Key a little
  5. press 0 to input ')' and then flutter program crash.

Expected results:

Actual results:

2022-07-30.06-40-32.mp4
Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: Center(
          child: Focus(
            onFocusChange: (bool hasFocus) => print(hasFocus),
            child: TextField(
              controller: TextEditingController(),
              textAlign: TextAlign.left,
              decoration: const InputDecoration(hintText: 'sample'),
            ),
          ),
        ),
      ),
    );
  }
}
flutter doctor -v [√] Flutter (Channel beta, 3.3.0-0.1.pre, on Microsoft Windows [Version 10.0.22622.436], locale ko-KR) • Flutter version 3.3.0-0.1.pre on channel beta at C:\Users\kimjuhwan\Documents\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision d952ca8 (2 days ago), 2022-07-27 10:33:00 -0700 • Engine revision fd131c385e • Dart version 2.18.0 (build 2.18.0-271.4.beta) • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at C:\Users\kimjuhwan\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.5)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.1.32414.318
• Windows 10 SDK version 10.0.20348.0

[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] IntelliJ IDEA Ultimate Edition (version 2021.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2
• Flutter plugin version 64.0.3
• Dart plugin version 212.5632

[√] IntelliJ IDEA Ultimate Edition (version 2022.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2
• Flutter plugin version 69.0.4
• Dart plugin version 221.6008.15

[√] VS Code (version 1.61.1)
• VS Code at C:\Users\kimjuhwan\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22622.436]
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114
• Edge (web) • edge • web-javascript • Microsoft Edge 103.0.1264.49

[√] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

Logs
Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Debug service listening on ws://127.0.0.1:56752/YX01-kncxQ4=/ws
Syncing files to device Windows...
flutter: true
Unable to parse JSON message:
The document is empty.
Unable to parse JSON message:
The document is empty.

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================
Unable to parse JSON message:
The document is empty.

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================
Unable to parse JSON message:
The document is empty.

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================
Unable to parse JSON message:
The document is empty.
Unable to parse JSON message:
The document is empty.
Unable to parse JSON message:
The document is empty.
Unable to parse JSON message:
The document is empty.

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareK

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsfound in release: 3.3Found to occur in 3.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions