Clicking on "Email" Textfied (not obscureText), keyboard did not appears, or appears and disappers in 1 second
This issue occurs on ANDROID EMULATOR and MOBILE (real), both with android 16.
In short words:
If field is OBSCURED = TRUE show keyboard, if NOT didn't SHOW!
Clicking on PASSWORD (field) that is obscured = true, keyboard is appears as well. If I put this configuration on Email field AND REMOVE keyboardtype, works well.
How to reproduce
Create a project
flutter create teste --platforms linux,android
On main.dart, create a simple signin class generated with 2 fields (emais and password) and 1 signin button. I used generated by Gemini, ChatGPT or manually.
Notes:
* Nothing was changed on pubsec.yaml.
* flutter clean ; flutter pub get was run between test/changes.
* It works on past, for some reason, stop to work. I don't know when stopped.
* Tested with Flutter 3.47.0 and 3.47.9
* I had tried suggestions from Stack Overflow, Medium and others forums without success.
Code used, console logs and screenshots can be found on Github repository.
<https://github.com/RonaldoSCouto/TextField_Keyboard.git>
Basically: IMAGES NOT WORKING: Clicking on Email Field,FAIL for it Clicking on Password Field, OK for it
// Email field DIDN'T SHOW KEYBOARD
TextField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration(
labelText: 'Email',
hintText: 'Enter your email',
prefixIcon: Icon(Icons.email),
border: OutlineInputBorder(),
),
),
IMAGES after change Email field to OBSCURED: Email field as OBSCURED Password field stay the same, after Email obscured
// Email field SHOW KEYBOARD
TextField(
controller: _emailController,
//keyboardType: TextInputType.emailAddress,
obscureText: _obscurePassword,
decoration: const InputDecoration(
labelText: 'Email',
hintText: 'Enter your email',
prefixIcon: Icon(Icons.email),
border: OutlineInputBorder(),
),
),
Scaffold block:
return Scaffold(
appBar: AppBar(title: const Text('Login'), centerTitle: true),
body: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Icon(Icons.account_circle, size: 90, color: Colors.blue),
const SizedBox(height: 32),
// Email field
TextField(
controller: _emailController,
//keyboardType: TextInputType.emailAddress,
obscureText: _obscurePassword,
decoration: const InputDecoration(
labelText: 'Email',
hintText: 'Enter your email',
prefixIcon: Icon(Icons.email),
border: OutlineInputBorder(),
),
),
const SizedBox(height: 16),
// Password field
TextField(
controller: _passwordController,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'Password',
hintText: 'Enter your password',
prefixIcon: const Icon(Icons.lock),
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: Icon(
_obscurePassword
? Icons.visibility
: Icons.visibility_off,
),
onPressed: () {
setState(() {
_obscurePassword = !_obscurePassword;
});
},
),
),
),
const SizedBox(height: 24),
// Login button
ElevatedButton(
onPressed: _login,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
),
child: const Text('Login'),
),
// Create account button
TextButton(
onPressed: _createAccount,
child: const Text('Create Account'),
),
],
),
),
),
);
Manifest.xml (As generated by Flutter create)
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="teste"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest><manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="teste"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>