[英]Keyboard covers TextField in Flutter
I have the problem that whenever I want to type something into my Textfield, the Keyboard covers it.我遇到的问题是,每当我想在文本字段中输入内容时,键盘都会覆盖它。 I expected the screen to just scroll up whenever the keyboard appears.
我希望只要键盘出现,屏幕就会向上滚动。 Any thoughts on that?
对此有什么想法吗? I tried to set resizeToAvoidBottomInsert to true and also to wrap everything into a SingleChildScrollView().
我尝试将 resizeToAvoidBottomInsert 设置为 true,并将所有内容都包装到 SingleChildScrollView() 中。
Here is my code:这是我的代码:
class PhoneNrInput extends StatelessWidget {
final TextEditingController phoneNrController = TextEditingController();
final FocusNode phoneNrFocusNode = FocusNode();
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: true,
body: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
height: 200,
width: double.infinity,
decoration: BoxDecoration(
boxShadow: [BoxShadow(color: Colors.black, blurRadius: 5)],
color: Color(0xff05111f),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
child: Padding(
padding: EdgeInsets.all(30),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 15,
),
Flexible(
fit: FlexFit.tight,
//Textfield
child: TextField(
focusNode: phoneNrFocusNode,
autofocus: false,
autocorrect: false,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
filled: true,
hintStyle: TextStyle(
color: Colors.black,
),
border: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(25),
),
fillColor: Colors.white,
hintText: "Telefonnummer",
),
controller: phoneNrController,
),
),
],
),
SizedBox(
height: 25,
),
ButtonTheme(
height: 40,
child: RaisedButton(
onPressed: () {},
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
child: Text("Registrieren"),
),
),
],
),
),
),
],
),
);
}
}
In case someone else has the same issue: I had included the following line in the section of the styles.xml file in the android/app/src/main/res/values folder:如果其他人有同样的问题:我在 android/app/src/main/res/values 文件夹中的 style.xml 文件部分包含了以下行:
<item name="android:windowFullscreen">true</item>
That caused the problem.这导致了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.