按下Flutter后退按钮,不隐藏Android 10上的键盘



通常,如果我们按下后退按钮,键盘会隐藏,但与本视频中一样,当重复按下后退按钮时,键盘不会隐藏。但在安卓7的测试中,当我按下隐藏的键盘后退按钮时,它运行得很好。

像这样https://user-images.githubusercontent.com/11581453/94370563-64b50480-0123-11eb-9329-4a52aaeb6aaa.gif

这是我的输入代码

TextFormField(
validator: (e) {
var message;
if (e.isEmpty) {
message = emailEmpty;
}
return message;
},
onSaved: (e) => email = e,
decoration: InputDecoration(
prefixIcon: Icon(
Icons.email,
color: Color(0xFF003d64),
),
labelText: emailInput,
),
),

flutter doctor -v

[✓] Flutter (Channel beta, 1.22.0-12.1.pre, on Mac OS X 10.15.6 19G2021, locale en-ID)
• Flutter version 1.22.0-12.1.pre at / Users / abedputra / Development / flutter
• Framework revision 8b3760638a (12 days ago), 2020-09-15 17:47:13 -0700
• Engine revision 4654fc6cf6
Dart version 2.10.0 (build 2.10.0-110.3.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at / Users / abedputra / Library / Android / sdk
• Android-R platform, build-tools 29.0.3
• Java binary at: / Applications / Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
• CocoaPods version 1.9.3
[✓] Chrome - develop for the web
• Chrome at / Applications / Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.0)
• Android Studio at / Applications / Android Studio.app/Contents
• Flutter plugin version 50.0.2-dev.1
• Dart plugin version 193.7547
Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] Connected device (3 available)
• K88 (mobile) 6acdf2f6 android-arm64 Android 7.1.1 (API 25)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 85.0.4183.121

已经从Flutter Github页面修复了这里。

要修复它,请从Beta频道更改为StableMaster通道。

更新

Flutter在Betachannel 1.22.0 • channel beta(2020-10-01(发布了一个新版本,该问题已经解决。

感谢

尝试将dispose方法添加到类State(Widget(:

@override
void dispose() {
// TODO: implement dispose
super.dispose();
}

最新更新