I am experiencing a critical issue where the soft keyboard immediately dismisses (within ~200ms) after a user taps a TextField. This prevents any text input and effectively blocks the user flow.
The Bug:
User taps the TextField.
The keyboard begins to animate up.
Before completing the animation, the keyboard "bounces" and closes automatically.
The TextField loses focus immediately.
Devices & OS Versions Affected:
vivo X300 / Motorola Edge 50 Pro: Android 16 Beta (API 36)
OnePlus 11: OxygenOS 16.0.3.500
realme 9 Pro+: Android 14 (showing similar regression)
Technical Context: This appears to be related to the mandatory Edge-to-Edge enforcement in Android 16. As the keyboard resizes the window, the "Window Inset" transition seems to trigger a layout collision or a "pointer cancel" event that Flutter interprets as a request to unfocus.
What I have tried:
Defining TextEditingController and FocusNode in initState (to prevent rebuild-related focus loss).
Setting resizeToAvoidBottomInset: true on the Scaffold.
Wrapping the input area in a SafeArea and SingleChildScrollView.
Testing both adjustResize and adjustPan in the AndroidManifest.xml.
Removing background GestureDetectors to rule out accidental unfocus() calls.
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: LoginScreen()));
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final FocusNode _focusNode = FocusNode();
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: true,
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 300), // Push field toward bottom
TextField(
focusNode: _focusNode,
decoration: const InputDecoration(hintText: "Enter Mobile Number"),
),
],
),
),
),
);
}
}