Skip to content

RawKeyboard has stuck keys on Android when switching focus between Flutter and native views #48899

Description

@ds84182

Essentially, Flutter doesn't receive a key up event when the activity is in the background, so if you hold a key slightly too long when invoking an action, you won't be able to use other shortcuts when you come back to the app.

You can reproduce this with an app that uses url_launcher to launch the browser on button press:

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: SafeArea(
          child: Column(
            children: <Widget>[
              FlatButton(
                onPressed: () => launch('https://example.com'),
                child: Text('Launch'),
              ),
              FlatButton(
                onPressed: () => launch('https://example.com'),
                child: Text('Also Launch'),
              ),
              FlatButton(
                onPressed: () {},
                child: Text('Does Nothing'),
              ),
            ],
          )
        ),
      ),
    );
  }
}

cc @gspencergoog

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: desktopRunning on desktopa: existing-appsIntegration with existing apps via the add-to-app flowa: text inputEntering text in a text field or keyboard related problemsf: focusFocus traversal, gaining or losing focusframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions