Skip to content

[Add2App] The typed characters in a TextField are lost when backgrounding the app with focus on the TextField on Android #47137

@dannyvalentesonos

Description

@dannyvalentesonos

Using the new embedding API for Android to embed Flutter in an existing app, it is possible for the TextField to lose its last typed characters when backgrounding the app on Android.

The following simple Flutter module code will create a TextField.

Launch the Flutter module in the existing app
Start typing text in the field
With focus still in the field, background the app using the Home button
Come back to the app. Notice the focus is still in the field and the keyboard is hidden, but the characters disappear.

If you take focus off of the TextField before backgrounding the app, then when coming back, the characters remain.

This is related to #35054, but the fix for that bug either introduced this or revealed it.

The following is the code in the flutter module:

// Main app entry
void main() {
   runApp(MyApp());
}

class DefaultEmptyPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
            child: TextField(
              decoration: InputDecoration(
                  labelText: "Enter Text"
              ),
            )
        )
    );
  }
}

class MyApp extends StatelessWidget {
  MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'My App',
      home: DefaultEmptyPage(),
    );
  }
}

Metadata

Metadata

Assignees

Labels

a: existing-appsIntegration with existing apps via the add-to-app flowa: text inputEntering text in a text field or keyboard related problemscustomer: crowdAffects or could affect many people, though not necessarily a specific customer.frameworkflutter/packages/flutter repository. See also f: labels.platform-androidAndroid applications specificallywaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions