-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Textfield obscureText interaction exception #140369
Comments
Thanks for filing this @ASooner. Screen record
Simulator.Screen.Recording.-.iPhone.15.-.2023-12-19.at.10.58.48.mp4Code Sample Used
import 'package:flutter/material.dart';
void main() {
runApp(
const MaterialApp(
title: 'Scroll test',
home: MyHomePage(),
initialRoute: '/',
debugShowCheckedModeBanner: false,
),
);
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text('Demo'),
),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
key: Key('a'),
keyboardType: TextInputType.numberWithOptions(signed: true),
decoration: InputDecoration(hintText: ' a obscureText false')),
TextField(
key: Key('c'),
keyboardType: TextInputType.text,
obscureText: true,
decoration: InputDecoration(hintText: ' c obscureText true')),
],
),
),
);
}
}
flutter doctor -v
|
480.movI think this has something to do with the security keyboard. After 15 seconds, it becomes normal after turning off the security keyboard. The same problem was also found in VIVO (Android 12) phones |
Thanks for your response @ASooner |
I debugged a Xiaomi 11 (Android 13) and did not find this problem. It seems that only some mobile phone systems have this problem. In vivo mobile phones, this problem occurs in Android 12 and Android 13. Huawei mobile phone system HarmonyOS 4 has this problem. HarmonyOS 3 no problem. |
Issue is assigned to multiple teams (android, design). Please ensure the issue has only one |
We're marking this issue as a P3 because we unfortunately do not have access to these devices. If someone in the community is able to work on this issue, we would definitely accept a fix! |
#143828 please fix it ,thanks! |
I also encountered the same problem and tried many methods but nothing worked. But you can try this. Although the effect is not very good, it works. TextField(
onTap: () {
if (!widget.focusNode.hasFocus) {
Future.delayed(150.milliseconds, () {
widget.focusNode.requestFocus();
});
}
},
controller: widget.controller,
focusNode: widget.focusNode,
obscureText: true,
decoration: const InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.zero,
),
) |
f549b09d0bd9e512fec403cba31028dc.mp4 |
The same problem 18806dd31169639fdd7b82a387f10e29.mp4 |
Also occurs on iPhone 11 running iOS 17.4.1 |
Hey, trying this,
1. Using Listener wrapper your TextField
2. Call unfocus() in onPointerDown
3. Then the TextField still focus by default
Problem solved.
Listener(
onPointerDown: (e) => {
FocusScope.of(context).unfocus(),
},
child: TDInput(
type: TDInputType.cardStyle,
width: context.widthPx - 20,
leftIcon: const Icon(TDIcons.mail),
leftLabel: 'Email',
backgroundColor: Colors.white,
hintText: 'Please input email',
onChanged: (email) {
debug(email);
controller.email.value = email;
},
),
) |
我的vivo/iqoo手机也出现了相同问题,可能是因为在打开‘安全输入’功能之后,会在软键盘弹出的时候系统增加一层window,这个window会抢占焦点,这是防止录屏等功能的时候密码泄露所开发的,如果你使用Android Studio 的Start Mirroring 功能,你会发现当获取焦点之后屏幕是黑色的 |
Steps to reproduce
Expected results
The keyboard should not disappear and reappear. It should directly determine the keyboard type and focus on the new textfield.
Actual results
The keyboard animation pops up and disappears abnormally. The cursor disappears and needs to be clicked again to focus.
Upgrading from 3.10.0 to 3.16.0 appears, in HarmonyOS 4,
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: