问题描述
@override
Widget build(BuildContext context) {
final bottom = MediaQuery.of(context).viewInsets.bottom;
return Scaffold(
resizetoAvoidBottomInset: false,resizetoAvoidBottomPadding: false,body: SingleChildScrollView(
reverse: true,child: Padding(
padding: EdgeInsets.only(bottom: bottom),child: Column(
children: <Widget>[
SizedBox(height: 48),Image.asset(
"assets/images/logo.png",width: 132,),SizedBox(height: 48),Form(
child: Column(
children: <Widget>[
AuthTextFormField(
icon: Icons.email_outlined,labelText: 'Email',keyboardType: TextInputType.emailAddress,AuthTextFormField(
icon: Icons.lock_outline,labelText: 'Password',obscureText: true,],);
}
我已关注此 answer,但它仍然不适合我。键盘仍然覆盖了文本字段。有什么想法吗?
谢谢。
[更新] 我使用上面的答案中编写的代码(由 Jay Jay)。而且,这是截图:
解决方法
这个 Code
对我来说很好用,我已经删除了 image
并在它的位置添加了一个 Container
和一些 height
。
我还对您的代码进行了一些更改,
Scaffold(
resizeToAvoidBottomPadding: true,body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(bottom: bottom),child: Column(
children: <Widget>[
SizedBox(height: 48),Container(
color: Colors.blue,height: 500,),SizedBox(height: 48),Form(
child: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(
icon: Icon(Icons.email),labelText: 'Email'),keyboardType: TextInputType.emailAddress,TextFormField(
decoration: InputDecoration(
icon: Icon(Icons.lock_outline),labelText: 'Password'),obscureText: true,TextFormField(
decoration: InputDecoration(
icon: Icon(Icons.email),],);
,
尝试后,我认为您应该只为 image.asset 添加一个高度,或者更好地使用 Container 并在其装饰属性中指定图像并为容器提供固定高度。它应该都能正常工作。
这里我的代码有效:
return Scaffold(
resizeToAvoidBottomInset: false,resizeToAvoidBottomPadding: false,body: SingleChildScrollView(
reverse: true,child: Padding(
padding: EdgeInsets.only(bottom: bottom),child: Column(
children: <Widget>[
SizedBox(height: 48),Container(
height: 300,color: Colors.red,Form(
child: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(
icon:Icon(Icons.email),labelText: 'Email'
),TextFormField(
decoration: InputDecoration(
icon: Icon(Icons.lock_outline),labelText: 'Password'
),);