本文介绍了resizeToAvoidBottomPadding 不起作用,键盘隐藏文本表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
resizeToAvoidBottomPadding (true and false) 功能不起作用,当文本框被点击时,文本表单仍然隐藏在后面.
resizeToAvoidBottomPadding (true and false) function not working,when textfield is tapped, the textform remains hidden behind.
也尝试了 resizeToAvoidBottomInset(true 和 false),但似乎没有任何效果.
Tried also with resizeToAvoidBottomInset (true and false) and nothing seems to work.
这是我的登录页面代码
import 'package:flutter/material.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => new _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomPadding: true,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(15.0, 110.0, 0.0, 0.0),
child: Text('Cons',
style: TextStyle(
fontSize: 80.0, fontWeight: FontWeight.bold)),
),
Container(
padding: EdgeInsets.fromLTRB(48.0, 175.0, 0.0, 0.0),
child: Text('Tech',
style: TextStyle(
fontSize: 80.0, fontWeight: FontWeight.bold)),
),
Container(
padding: EdgeInsets.fromLTRB(220.0, 175.0, 0.0, 0.0),
child: Text('.',
style: TextStyle(
fontSize: 80.0,
fontWeight: FontWeight.bold,
color: Colors.green)),
)
],
),
),
Container(
padding: EdgeInsets.only(top: 35.0, left: 20.0, right: 20.0),
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
labelText: 'EMAIL',
labelStyle: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.bold,
color: Colors.grey),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.green))),
),
SizedBox(height: 20.0),
TextField(
decoration: InputDecoration(
labelText: 'CONSTRASEÑA',
labelStyle: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.bold,
color: Colors.grey),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.green))),
obscureText: true,
),
SizedBox(height: 5.0),
Container(
alignment: Alignment(1.0, 0.0),
padding: EdgeInsets.only(top: 15.0, left: 20.0),
child: InkWell(
child: Text(
'Reestablecer Contraseña',
style: TextStyle(
color: Colors.green,
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat',
decoration: TextDecoration.underline),
),
),
),
SizedBox(height: 40.0),
Container(
height: 40.0,
child: Material(
borderRadius: BorderRadius.circular(20.0),
shadowColor: Colors.greenAccent,
color: Colors.green,
elevation: 7.0,
child: InkWell(
onTap: () {},
child: Center(
child: Text(
'LOGIN',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat'),
),
),
),
),
),
SizedBox(height: 20.0),
Container(
height: 40.0,
color: Colors.transparent,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
style: BorderStyle.solid,
width: 1.0),
color: Colors.transparent,
borderRadius: BorderRadius.circular(20.0)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Center(
child:
ImageIcon(AssetImage('assets/facebook.png')),
),
SizedBox(width: 10.0),
Center(
child: Text('Log in con facebook',
style: TextStyle(
fontWeight: FontWeight.bold,
fontFamily: 'Montserrat')),
)
],
),
),
)
],
)),
SizedBox(height: 15.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'No tienes cuenta ?',
style: TextStyle(fontFamily: 'Montserrat'),
),
SizedBox(width: 5.0),
InkWell(
onTap: () {
Navigator.of(context).pushNamed('/signup');
},
child: Text(
'Registro',
style: TextStyle(
color: Colors.green,
fontFamily: 'Montserrat',
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline),
),
)
],
)
],
));
}
}
我想点击密码字段,让整个脚手架向上移动,让用户看到当前正在输入的内容.
Id like to tap the password field and have the whole scaffold to move upwards to let the user see whats currently being typed.
这是我的颤振医生输出.
Heres my flutter doctor output.
[√] Flutter (Channel beta, v1.3.8, on Microsoft Windows [Version 10.0.17134.648], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.2)
[√] VS Code (version 1.32.3)
[√] Connected device (1 available)
• No issues found!
推荐答案
将第一个 Column
包裹在 SingleChildScrollView
中以允许滚动.
Wrap the first Column
inside SingleChildScrollView
to allow scrolling.
body: SingleChildScrollView(
child: Column(
...
这篇关于resizeToAvoidBottomPadding 不起作用,键盘隐藏文本表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!