-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
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(),
);
}
}