Skip to content

Getting an exception when pressing AltGr key for Flutter Web #113836

@warcayac

Description

@warcayac

Steps to Reproduce

  1. Run any Flutter Web with a TextFormField widget
  2. Focus on text box (in Chrome browser)
  3. Press AltGr key
  4. Debug Console shows an exception raised

Expected results:
No exception

Actual results:

══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following assertion was thrown during a platform message callback:
Assertion failed:
file:///home/warcayac/Applications/flutter/packages/flutter/lib/src/services/raw_keyboard.dart:682:7
../…/services/raw_keyboard.dart:682
event is! RawKeyDownEvent || _keysPressed.isNotEmpty
"Attempted to send a key down event when no keys are in keysPressed. This state can occur if the key
event being sent doesn't properly set its modifier flags. This was the event:
RawKeyDownEvent#0c4a4(logicalKey: LogicalKeyboardKey#9d80f(keyId: \"0x17032c92bb\", keyLabel: \"\",
debugName: \"Key with ID 0x017032c92bb\"), physicalKey: PhysicalKeyboardKey#700e6(usbHidUsage:
\"0x000700e6\", debugName: \"Alt Right\"), repeat: false) and its data:
RawKeyEventDataWeb#c5204(code: AltRight, key: AltGraph, location: 2, metaState: 0, keyCode: 225)"
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49      throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3        assertFailed
packages/flutter/src/services/raw_keyboard.dart 682:49                            handleRawKeyEvent
packages/flutter/src/services/hardware_keyboard.dart 878:30                       handleRawKeyMessage
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 123:5                _async
packages/flutter/src/services/hardware_keyboard.dart 850:51                       handleRawKeyMessage
packages/flutter/src/services/platform_channel.dart 197:49                        <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 123:5                _async
packages/flutter/src/services/platform_channel.dart 196:58                        <fn>
packages/flutter/src/services/binding.dart 387: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 123:5                _async
packages/flutter/src/services/binding.dart 384:98                                 <fn>
lib/_engine/engine/platform_dispatcher.dart 1199:13                               invoke2
lib/ui/channel_buffers.dart 25:12                                                 invoke
lib/ui/channel_buffers.dart 65:7                                                  push
lib/ui/channel_buffers.dart 130:16                                                push
lib/_engine/engine/platform_dispatcher.dart 364:25                                invokeOnPlatformMessage
lib/_engine/engine/keyboard.dart 130:39                                           [_handleHtmlEvent]
lib/_engine/engine/keyboard.dart 32:7                                             <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 334:14  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 339:39  dcall
════════════════════════════════════════════════════════════════════════════════════════════════════
Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'core/app/theme.dart';
import 'shared/responsive/device.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();  // importante

  if (WDevice.isAndroid) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( // only Android
      statusBarColor: Colors.transparent,
    ));
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);  // Android only
  }

  Paint.enableDithering = true;

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    WDevice.context = context;
    return _buildMaterialApp(context);
  }
  Widget _buildMaterialApp(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      debugShowCheckedModeBanner: false,
      theme: WApp.material.getThemeData(context),
      home: Scaffold(
        body: Center(
          child: TextField(),
        ),
      ),
    );
  }
}
Logs **FLUTTER RUN VERBOSE** is moved to next comment because exceeded limit of chars.

....

$ flutter analyze                
Analyzing demodemo...                                                   
No issues found! (ran in 2.3s)
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.3.5, on EndeavourOS 6.0.2-zen1-1-zen, locale en_US.UTF-8)
    • Flutter version 3.3.5 on channel stable at /home/warcayac/Applications/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d9111f6402 (2 days ago), 2022-10-19 12:27:13 -0700
    • Engine revision 3ad69d7be3
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /home/warcayac/Android/Sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_SDK_ROOT = /home/warcayac/Android/Sdk
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /bin/google-chrome-stable

[✓] Android Studio (version 2021.3)
    • Android Studio at /opt/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.13+0-b1751.21-8125866)

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 106.0.5249.119

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

• No issues found!

output

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consoleengineflutter/engine repository. See also e: labels.found in release: 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions