[英]Keyboard is closing after clicking on TextFormField in flutter
[英]Flutter - keyboard over TextFormField
我在應用程序中有某種登錄頁面。 但是,當我關注 TextFormField 時,鍵盤覆蓋了字段,什么也看不見。 作為 Android 開發者,
我通常通過將android:windowSoftInputMode="adjustResize|stateHidden
到清單來修復它。
在 Flutter 中如何解決?
代碼:
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: ListView(
children: <Widget>[
Center(child: Image(image: AssetImage("images/uhk.jpg"))),
Form(
key: formKey,
child: Padding(
padding: EdgeInsets.only(top: 20.0, left: 30.0, right: 30.0),
child: Column(
children: <Widget>[
TextFormField(
decoration:
new InputDecoration(labelText: "Přihlašovací jméno"),
maxLines: 1,
keyboardType: TextInputType.emailAddress,
onSaved: (String value) => ""),
TextFormField(
decoration: new InputDecoration(labelText: "Heslo"),
maxLines: 1,
obscureText: true,
onSaved: (String value) => ""),
],
),
),
),
Padding(
padding: EdgeInsets.only(top: 50.0, left: 30.0, right: 30.0),
child: RaisedButton(
child: Text("Přihlásit se",
style: TextStyle(
fontSize: 16.0, color: Colors.white, height: 3.0)),
color: Colors.lightBlue,
onPressed: () => "")),
Padding(
padding: EdgeInsets.only(
top: 20.0,
),
child: Center(
child: FlatButton(
onPressed: () => "",
child: Text("Vytvořit účet",
style: TextStyle(fontSize: 14.0, color: Colors.grey)),
))),
],
),
}
//Add this line "resizeToAvoidBottomInset: true," to your Scaffold and put your main container in ScrollView.
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: true,
key: _scaffoldKey,
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Container()
),
);
}
可在此處找到完整詳細的解決方案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.