颤动:当TextView聚焦时,OnScreen键盘无法打开

问题描述 投票:2回答:1

我正在尝试使用Firebase身份验证(电子邮件/密码)为应用创建一个简单的登录和注册屏幕。在物理设备和仿真器上进行测试时,当TextView聚焦时,屏幕键盘不会弹出。有时,另一个我无法识别的屏幕在运行一瞬间后立即弹出,但不是每次都会弹出。

在我意识到我忘记导入async之后它工作了一次,它似乎工作。稍后恢复工作后,键盘突然再次打开。我已经尝试删除几乎所有代码并只留下UI,但屏幕键盘没有显示。

Code

void main() => runApp(MaterialApp(title: 'Login Test', home: LoginScreen()));

final FirebaseAuth _auth = FirebaseAuth.instance;
class LoginScreen extends StatelessWidget {
    TextEditingController _uname = TextEditingController();
    TextEditingController _pword = TextEditingController();

    Future<FirebaseUser> _handleSignIn(var context, String email, String password) async{
        AlertDialog dialog = new AlertDialog(
            content: new Text("Loading...")
        );
        showDialog(context: context, builder: (BuildContext context) => dialog);
        _auth.signInWithEmailAndPassword(email: email, password: password).then((FirebaseUser user) {
            print("success");
        }).catchError((e) => print(e));
        Navigator.pop(context);
        return _auth.currentUser;
    }

    @override
    Widget build(BuildContext context) {
            Container loginScreen;
            TextField username = TextField(controller: _uname, decoration: InputDecoration(labelText: "Email",), keyboardType: TextInputType.emailAddress, );
            TextField password = TextField(controller: _pword, decoration: InputDecoration(labelText: "Password",), keyboardType: TextInputType.text, obscureText: true,);
            RaisedButton login = RaisedButton(child: Text("Login"),
                onPressed: (){ _handleSignIn(context, _uname.text.toString(), _pword.text.toString()); }
            );
            loginScreen = Container(child: Column(children: [username, password, login]), padding: EdgeInsets.all(16));
            return Scaffold(appBar: AppBar(title: "Login Screen"), body: loginScreen); 
    }
}

颤动医生输出:

[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17763.437], locale en-US)
• Flutter version 1.0.0 at C:\flutter
• Framework revision 5391447fae (5 months ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at C:\Users\laury\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.

[√] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 34.0.2
• Dart plugin version 183.5901
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[√] VS Code (version 1.30.2)
• VS Code at C:\Users\laury\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 2.22.3

[√] Connected device (1 available)
• moto g 7 • ZY225F2VS7 • android-arm64 • Android 9 (API 28)

• No issues found!

根据我读过的大多数文档,当TextView被聚焦/选择时键盘应该打开,但是由于我似乎无法固定的原因它不能打开。

我该如何解决这个问题?

firebase dart flutter firebase-authentication textview
1个回答
0
投票

这是bug的一些旧版本中的Flutter。执行flutter upgrade将解决它。

这个link包含有关如何升级颤振的信息

© www.soinside.com 2019 - 2024. All rights reserved.