Skip to content

A KeyUpEvent is dispatched, but the state shows that the physical key is not pressed. #149176

@shahzaibdev1

Description

@shahzaibdev1

Steps to reproduce

  1. Use the following code for changing the route:
Navigator.pushReplacement(
          context,
          MaterialPageRoute(
            builder: (context) {
              return Builder(
                builder: (context) {
                  return TranslationDetails(text: lst, customPaint: _customPaint!, image: uiImage);
                },
              );
            },
          ),
        ).then((value) => _startLiveFeed);
  1. Navigate to the TranslationDetails screen.
  2. Press the back button (bottom/phone's native) to return to the previous screen.
  3. Observe the error in the console.

Environment:

  • Flutter version: 3.19.5
  • Framework • revision 300451a (9 weeks ago) • 2024-03-27 21:54:07 -0500
  • Engine • revision e76c956498
  • Platform: Android
  • Tools • Dart 3.3.3 • DevTools 2.31.1

Additional Information:

  • No physical keyboard is attached to the device.
  • The issue occurs with a 1-second delay/lag.

Expected results

The application should navigate between screens without any delay or error, regardless of the physical keyboard's status.

Actual results

════════ Exception caught by services library ══════════════════════════════════
A KeyUpEvent 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: KeyUpEvent#64ad8(physicalKey: PhysicalKeyboardKey#3b725(usbHidUsage: "0x1100000004", debugName: "Key with ID 0x1100000004"), logicalKey: LogicalKeyboardKey#5dfc4(keyId: "0x100001005", keyLabel: "Go Back", debugName: "Go Back"), character: null, timeStamp: 0:00:27.768097)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 509 pos 16: '_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════

Code sample

Code sample
Navigator.pushReplacement(
          context,
          MaterialPageRoute(
            builder: (context) {
              return Builder(
                builder: (context) {
                  return TranslationDetails(text: lst, customPaint: _customPaint!, image: uiImage);
                },
              );
            },
          ),
        ).then((value) => _startLiveFeed);

Screenshots or Video

No response

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
PS D:\translation_app> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.19045.4412], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.6)
[√] Android Studio (version 2022.3)
[√] VS Code (version 1.89.1)
[√] Connected device (6 available)
[√] Network resources

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions