-
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 text content disappears #90256
Comments
@changleibox Thanks for filing the issue.
I am not sure I understand what you meant by this? I construed it as hiding and showing the keyboard if so I was not able to reproduce the issue and the text does not get disappeared. Screen.Recording.2021-09-17.at.4.55.35.PM.movflutter doctor -v
|
你好,感谢你的回复,是我的回复没有表达清楚,不好意思,以下是我的复现代码: Translated via google translate Hello, thank you for your reply, my reply is not clear, sorry, the following is my recurring code: Exampleclass HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final _controller = TextEditingController(text: '1');
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).unfocus();
},
child: Scaffold(
appBar: AppBar(
title: const Text('TextField设置了KeyboardType,在频繁切换键盘,文本内容消失'),
),
body: ListView(
padding: const EdgeInsets.all(10),
children: [
TextField(
controller: _controller,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
hintText: '请输入',
contentPadding: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 10,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).dividerColor,
width: 0,
),
),
),
keyboardType: TextInputType.number,
),
],
),
),
);
}
} |
这是我的复现视频 Translated via google translate This is my recurring video 2021-09-18.10.19.40.movflutter doctor -v[✓] Flutter (Channel stable, 2.5.0, on macOS 11.6 20G165 darwin-x64, locale zh-Hans-CN)
• Flutter version 2.5.0 at /Users/changlei/Downloads/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4cc385b4b8 (10 days ago), 2021-09-07 23:01:49 -0700
• Engine revision f0826da7ef
• Dart version 2.14.0
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/changlei/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = /Users/changlei/Library/Android/sdk
• Java binary at: /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 14.0.1+7)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/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)
[✓] IntelliJ IDEA Community Edition (version 2020.3.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin version 203.7759
[✓] VS Code (version 1.58.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.24.0
[✓] Connected device (3 available)
• iPad Pro (11-inch) (3rd generation) (mobile) • 9D89D4DD-4B46-4A6F-999D-BABBB2808A98 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 11.6 20G165 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82
• No issues found! |
Hi @changleibox thanks for the video, but I am not able to reproduce the issue on stable 2.5.0 or 2.5.1 could you please try upgrading to the latest stable 2.5.1 and see if it fixes the issue. code sampleimport 'package:flutter/material.dart';
// void main() => runApp(const MyApp());
void main() {
runApp(MyApp());
}
final darkNotifier = ValueNotifier<bool>(false);
class MyApp extends StatelessWidget {
MyApp({Key? key}) : super(key: key);
TextEditingController username = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(title: 'Flutter Demo', home: HomePage());
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final _controller = TextEditingController(text: '1');
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).unfocus();
},
child: Scaffold(
appBar: AppBar(
title: const Text('TextField设置了KeyboardType,在频繁切换键盘,文本内容消失'),
),
body: ListView(
padding: const EdgeInsets.all(10),
children: [
TextField(
controller: _controller,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
hintText: '请输入',
contentPadding: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 10,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).dividerColor,
width: 0,
),
),
),
keyboardType: TextInputType.number,
),
],
),
),
);
}
}
Screen.Recording.2021-09-20.at.10.51.30.AM.movflutter doctor -v
|
In flutter 2.3 the list view ddidn't reload when soft keyboard opens. After upgarding to flutter 2.5.0. Opening soft keyboard forces the list view to rebuild. |
你好,感谢你的回复,我在flutter2.5.1无法复现此问题,看来是已经修复了,谢谢你 Edited translated from Google translate Hello, thank you for your reply, I cannot reproduce this problem in flutter 2.5.1, it seems that it has been fixed, thank you |
@changleibox provided your last comment I feel its safe to close this issue, Closing as fixed in newer version if you disagree feel free to write in the comments and I will reopen it. Thank you. |
@neelansh-creatorstack, That seems to be a different issue, Please file a separate issue describing the exact steps with the output of Thanks. |
@maheshmnj 你好,又要打扰你了,我又在flutter2.5.1上复现了这个问题,麻烦再帮忙看一下,谢谢 translated using google translate @maheshmnj Hello, I’m going to disturb you again, I reproduced this problem on flutter 2.5.1, please help me take a look again, thank you 2021-09-18.10.19.40.movcode sampleimport 'package:flutter/material.dart';
// void main() => runApp(const MyApp());
void main() {
runApp(MyApp());
}
final darkNotifier = ValueNotifier<bool>(false);
class MyApp extends StatelessWidget {
MyApp({Key? key}) : super(key: key);
TextEditingController username = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(title: 'Flutter Demo', home: HomePage());
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final _controller = TextEditingController(text: '1');
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).unfocus();
},
child: Scaffold(
appBar: AppBar(
title: const Text('TextField设置了KeyboardType,在频繁切换键盘,文本内容消失'),
),
body: ListView(
padding: const EdgeInsets.all(10),
children: [
TextField(
controller: _controller,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
hintText: '请输入',
contentPadding: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 10,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).dividerColor,
width: 0,
),
),
),
keyboardType: TextInputType.number,
),
],
),
),
);
}
} flutter doctor -v[✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-x64, locale zh-Hans-CN)
• Flutter version 2.5.1 at /Users/changlei/Downloads/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffb2ecea52 (7 days ago), 2021-09-17 15:26:33 -0400
• Engine revision b3af521a05
• Dart version 2.14.2
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/changlei/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = /Users/changlei/Library/Android/sdk
• Java binary at: /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 14.0.1+7)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.0, Build version 13A233
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/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)
[✓] IntelliJ IDEA Community Edition (version 2020.3.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin version 203.7759
[✓] VS Code (version 1.58.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.24.0
[✓] Connected device (3 available)
• iPad Pro (11-inch) (3rd generation) (mobile) • 34DDC767-BF9A-4B6D-8701-CDD0539C541F • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 11.6 20G165 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82
• No issues found! |
Reopening the issue for further investigation based on the above comment. |
@changleibox could you please also verify on other devices as well to understand if this issue is device / OS-version specific. Thanks |
@maheshmnj 你好,我用iPhone 13 Pro Max - iOS 15.0模拟器,无法复现此问题,在iPad Pro (11-inch) 3rd generation - iOS 15.0模拟器上,可以百分百复现此问题。 Translated via Google translate Hello @maheshmnj, I use iPhone 13 Pro Max-iOS 15.0 simulator, this problem cannot be reproduced. On iPad Pro (11-inch) 3rd generation-iOS 15.0 simulator, this problem can be reproduced 100%. |
@changleibox Thanks for verifying, I can't reproduce the issue so labeling this issue for further investigation from the team. |
This is the translated version of the original issue via google translate
Steps to Reproduce
keyboardType
property toTextInputType.number
.Expected results:
The content is always displayed unless the content is manually cleared
Actual results:
The TextField with
keyboardType
is set, and the content disappears when the keyboard display state is switchedOriginal Issue
Steps to Reproduce
keyboardType
属性为TextInputType.number
.Expected results:
除非手动清除内容,否则一直显示内容
Actual results:
设置了
keyboardType
的TextField,切换键盘显示状态时,内容消失Logs
Example
The text was updated successfully, but these errors were encountered: