Thanks to visit codestin.com
Credit goes to github.com

Skip to content

iOS Keyboard flickers when switching the TextFields which have obscureText set to true #88354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
afnx opened this issue Aug 17, 2021 · 26 comments
Labels
a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@afnx
Copy link

afnx commented Aug 17, 2021

Switching the TextFields which have obscureText set to true causes iOS Keyboard with AutoFill Passwords enabled to flicker. This also affects the widgets due to the change in the keyboard height. There is apparently no issue when AutoFill Passwords is disabled.

issue.mp4

Steps to Reproduce

  1. Open Settings on iOS Simulator or an iPhone.
  2. Go to Passwords.
  3. Add a new password (if you haven't before).
  4. Go to AutoFill Passwords.
  5. Enable AutoFill Passwords.
  6. Run the Flutter code below:
minimal code sample
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Test',
      debugShowCheckedModeBanner: false,
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Test'),
      ),
      body: SafeArea(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Expanded(
              child: SingleChildScrollView(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  mainAxisSize: MainAxisSize.max,
                  children: <Widget>[
                    TextField(
                      obscureText: true,
                      decoration: InputDecoration(
                        hintText: "Obscure TextField 1",
                      ),
                    ),
                    TextField(
                      obscureText: true,
                      decoration: InputDecoration(
                        hintText: "Obscure TextField 2",
                      ),
                    ),
                    TextField(
                      obscureText: true,
                      decoration: InputDecoration(
                        hintText: "Obscure TextField 3",
                      ),
                    ),
                  ],
                ),
              ),
            ),
            ElevatedButton(
              onPressed: () {
                print('pressed');
              },
              child: Text('Button'),
            ),
          ],
        ),
      ),
    );
  }
}
  1. Switch between TextFields.
  2. Notice that the keyboard flickers and causes the button to flicker as well.

Details

@LongCatIsLooong
Copy link
Contributor

I can confirm this doesn't happen with the same setup in a UIKit app. @afnx does it stop flickering if you put all 3 TextFields in an AutofillGroup?

@TahaTesser TahaTesser added the in triage Presently being triaged by the triage team label Aug 18, 2021
@afnx
Copy link
Author

afnx commented Aug 18, 2021

@LongCatIsLooong, the issue still persists after using AutofillGroup.

@TahaTesser
Copy link
Member

Hi @afnx
Thanks for filing the issue, looks similar to #80423, I can reproduce the issue on multiple channels

Used the following minimal code sample

complete minimal runnable code sample
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      theme: ThemeData.dark(),
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Material App Bar'),
      ),
      body: AutofillGroup(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          children: <Widget>[
            TextField(
              obscureText: true,
              decoration: InputDecoration(
                hintText: "Obscure TextField 1",
              ),
            ),
            TextField(
              obscureText: true,
              decoration: InputDecoration(
                hintText: "Obscure TextField 2",
              ),
            ),
            TextField(
              obscureText: true,
              decoration: InputDecoration(
                hintText: "Obscure TextField 3",
              ),
            ),
          ],
        ),
      ),
    );
  }
}
stable master

Check flutter doctor -v outputs for each channel below

flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 12.0 21A5304g darwin-x64, locale en-GB)
    • Flutter version 2.2.3 at /Users/tahatesser/Code/flutter_stable
    • Framework revision f4abaa0735 (7 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/tahatesser/Code/SDK
    • Platform android-31, build-tools 30.0.3
    • ANDROID_HOME = /Users/tahatesser/Code/SDK
    • Java binary at: /Users/tahatesser/Code/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode-beta.app/Contents/Developer
    • Xcode 13.0, Build version 13A5212g
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2020.3)
    • Android Studio at /Users/tahatesser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] VS Code (version 1.59.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.25.0

[✓] Connected device (4 available)
    • Taha’s iPhone (mobile) • 00008020-001059882212002E            • ios            • iOS 14.7.1
    • iPhone 12 (mobile)     • 7CC8A747-CD39-4C42-871C-2D1CCEAE2AE2 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-x64     • macOS 12.0 21A5304g darwin-x64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 92.0.4515.159

! Doctor found issues in 1 category.
[✓] Flutter (Channel master, 2.5.0-7.0.pre.130, on macOS 12.0 21A5304g darwin-x64, locale en-GB)
    • Flutter version 2.5.0-7.0.pre.130 at /Users/tahatesser/Code/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d83fba1a22 (5 hours ago), 2021-08-18 03:02:04 -0400
    • Engine revision a27da3eeb6
    • Dart version 2.15.0 (build 2.15.0-24.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/tahatesser/Code/SDK
    • Platform android-31, build-tools 30.0.3
    • ANDROID_HOME = /Users/tahatesser/Code/SDK
    • Java binary at: /Users/tahatesser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
    • Xcode at /Applications/Xcode-beta.app/Contents/Developer
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/tahatesser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/tahatesser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.59.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.25.0

[✓] Connected device (4 available)
    • Taha’s iPhone (mobile) • 00008020-001059882212002E            • ios            • iOS 14.7.1 18G82
    • iPhone 12 (mobile)     • 7CC8A747-CD39-4C42-871C-2D1CCEAE2AE2 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-x64     • macOS 12.0 21A5304g darwin-x64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 92.0.4515.159

• No issues found!

✅: No Issue ❌: Issue reproduced

@TahaTesser TahaTesser added a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-ios iOS applications specifically and removed in triage Presently being triaged by the triage team labels Aug 18, 2021
@LongCatIsLooong LongCatIsLooong added the P2 Important issues not at the top of the work list label Aug 31, 2021
@MahdiGharooni
Copy link
Contributor

Switching the TextFields which have obscureText set to true causes iOS Keyboard with AutoFill Passwords enabled to flicker. This also affects the widgets due to the change in the keyboard height. There is apparently no issue when AutoFill Passwords is disabled.

issue.mp4

Steps to Reproduce

  1. Open Settings on iOS Simulator or an iPhone.
  2. Go to Passwords.
  3. Add a new password (if you haven't before).
  4. Go to AutoFill Passwords.
  5. Enable AutoFill Passwords.
  6. Run the Flutter code below:

minimal code sample

  1. Switch between TextFields.
  2. Notice that the keyboard flickers and causes the button to flicker as well.

Details

I had the same error when using obsecure = true in browser of iPhone
so I wrote a custom textFormField called passwordTextFormField, you can see my article in this link:
https://github.com/MahdiGharooni/flutter_macos_obscureText

@LinXunFeng
Copy link
Member

The problem is caused by iOS's autofill function, which can be resolved by turning it off

TextField(
  ...
  autofillHints: const <String>[AutofillHints.oneTimeCode],
  ...
)

@derekpankaew
Copy link

I'm having the same issue, where the screen flickers when the user moves between two fields. It occurs when the password field has obscureText set to true. It doesn't seem to matter whether autofill is enabled or not, or whether it's in an autofill group.

@MahdiGharooni - Did you say that disabling AutoFill Passwords helped? If so, can you describe how to do that? I've already tried:

  • Removing passwords from autofill group
  • autofillHints: null
  • enableSuggestions: false

I couldn't find any other way to disable AutoFill Passwords, would appreciate any help!

@MahdiGharooni
Copy link
Contributor

First, upgrade your Flutter SDK or change the Flutter branch (master, stable) maybe it's fixed.
Second, I used a custom textFormField with obscure=false. You can find it in my GitHub profile: https://github.com/MahdiGharooni/flutter_macos_obscureText
if you use it please share your comments

@derekpankaew
Copy link

I upgraded the Flutter SDK already, it's not fixed yet. I'll give the custom textFormField a try - thank you!

@CoolDude53
Copy link

@LongCatIsLooong bumping this

@meowofficial
Copy link

meowofficial commented Mar 5, 2023

@LongCatIsLooong In my case keyboard flikers on iPad after text submission if autoCorrect set to false.
Setting autoCorrect to false also causes the error:

[LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x280983160 'assistantHeight' SystemInputAssistantView.height == 55   (active, names: SystemInputAssistantView:0x100d98570 )>",
    "<NSLayoutConstraint:0x2809fce10 'assistantView.bottom' SystemInputAssistantView.bottom == _UIKBCompatInputView:0x100dc3710.top   (active, names: SystemInputAssistantView:0x100d98570 )>",
    "<NSLayoutConstraint:0x2809fc370 'assistantView.top' V:|-(0)-[SystemInputAssistantView]   (active, names: SystemInputAssistantView:0x100d98570, '|':UIInputSetHostView:0x12c1ce730 )>",
    "<NSLayoutConstraint:0x28098cf50 'inputView.top' V:|-(0)-[_UIKBCompatInputView:0x100dc3710]   (active, names: '|':UIInputSetHostView:0x12c1ce730 )>"
)


Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x2809fce10 'assistantView.bottom' SystemInputAssistantView.bottom == _UIKBCompatInputView:0x100dc3710.top   (active, names: SystemInputAssistantView:0x100d98570 )>


Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.```

@gonzalogauto
Copy link

Any updates on this? In my case if I set autocorrect: false the flickering goes away and I can still using obscureText + autofillHints

@dodatw
Copy link

dodatw commented May 14, 2023

This issue can reproduce on flutter 3.7.12, Is there any solution ?

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team labels Jul 8, 2023
@lukeurban
Copy link

Exist on channel stable, 3.13.2 as well.

@mittenimraum
Copy link

For me it started to appear with iOS 17 and having autofillHints set e.g.: [AutofillHints.username]. It is still present in the latest Beta Flutter 3.15.0-15.1.pre. When removing autofillHints the flickering disappears, which leads me to believe that the issue is connected to the autofill hints bar above the keyboard.

@aarcoraci
Copy link

It has started to happen to me as well since iOS17

@liplum
Copy link

liplum commented Sep 21, 2023

I can reproduce it on iOS 17.

As @LinXunFeng mentioned above, the code snippet could work. However it just breaks the password autofill feature on iOS.

TextField(
  // now the keyboard doesn't recognize the text field as a password field.
  autofillHints: const <String>[AutofillHints.oneTimeCode],
)

@aarcoraci
Copy link

seems to be related to:
#134723

In which case I see someone working on it 😄

@baptiste-veyrard
Copy link

Hi,

I got the same issue.
I am using FlutterFlow to build an app, so it is based on flutter and I have access to the flutter code.

I did several tests, and as soon as the field is considered as a password, the quicktype bar display the "password" option and it starts to flash/flicker.
Taking a classic textField, as soon as adding 'obscureText = true' the bug is triggered.
I try to add "autocorrect: false" but it did not work.

Did you find any solution?

I use Flutter 3.13.2.
I build the archive via Xcode.
I tested on several Iphone device simulators as well as on real devices, same results everywhere.

@AdamYogan
Copy link

AdamYogan commented Jun 25, 2024

Problem still exists...

Flutter 3.22.2

I have an authentication screen with username and password form fields. When I switch between fields, the keyboard size changes momentarily. The extra top space for password selection hides for a few milliseconds and then reverts to its previous state. I use an Expanded widget with an app logo, so everything resizes without any animation, which gives the app an unpleasant and unpolished feeling.

When I switch off autofillHints and obscureText, iOS doesn't identify those fields as username/password and doesn't show the keyboard's extra top space for password selection.

But this is not a solution... We need proper behaviour.

@anhquangtech
Copy link

Temporary solution (but it is not the best solution, problem still in flutter version 3.22.2).
I turned off autocorrect, autofillHints to use obscure text. This is my code:

obscureText: true or false, // you can use obscureText
autofillHints: const <String>[AutofillHints.oneTimeCode],
autocorrect: false,

Note: this is a temporary solution. We need proper behavior.

@AdamYogan
Copy link

Assignees: No one assigned

Guys, it's a joke. Is Flutter dead? Should we migrate to something else?

@AdamTechAcc
Copy link

Google, please do something with that issue.

@kamami
Copy link

kamami commented Nov 6, 2024

Any update?

@AdamTechAcc
Copy link

Any news? Bug is really ugly...

@AdamTechAcc
Copy link

I really like flutter, but this is not good... Should we switch to flock or other technology?

@JHeisecke
Copy link

for future devs coming here. This happens natively using SwiftUI, so it's not a flutter issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
Development

No branches or pull requests