resizeToAvoidBottomPadding(正确和错误)功能不起作用,当点击文本框时,文本格式仍然隐藏在后面。
还尝试过resizeToAvoidBottomInset(对与错),似乎没有任何作用。
这是我的登录页面代码
y
Id喜欢点击密码字段,并使整个支架向上移动,以使用户看到当前正在键入的内容。
这里是我扑扑的医生的输出。
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),
),
)
],
)
],
));
}
}
答案 0 :(得分:1)
Scaffold(
resizeToAvoidBottomPadding: true,//deprecated
在Flutter v1.1.9之后,不推荐使用 resizeToAvoidBottomPadding
。
Scaffold(
resizeToAvoidBottomInset: true,//use this
使用resizeToAvoidBottomInset
指定在键盘出现时主体是否应该调整大小。
答案 1 :(得分:1)
使用“ resizeToAvoidBottomInset”指定当键盘出现时主体是否应调整大小。 v1.1.9之后不推荐使用此功能。请使用“ resizeToAvoidBottomInset”代替“ resizeToAvoidBottomPadding”。
答案 2 :(得分:1)
将 resizeToAvoidBottomPadding
更改为“resizeToAvoidBottomInset
”
在终端运行
flutter clean
dart pub upgrade
在 index.html 中添加此脚本
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-firestore.js"></script>
<script>
// TODO: Replace the following with your app's Firebase project configuration.
// See: https://support.google.com/firebase/answer/7015592
var firebaseConfig = {
apiKey: "...",
authDomain: "[YOUR_PROJECT].firebaseapp.com",
databaseURL: "https://[YOUR_PROJECT].firebaseio.com",
projectId: "[YOUR_PROJECT]",
storageBucket: "[YOUR_PROJECT].appspot.com",
messagingSenderId: "...",
appId: "1:...:web:...",
measurementId: "G-..."
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
<script src="main.dart.js" type="application/javascript"></script>
答案 3 :(得分:0)
在Column
内包裹第一个SingleChildScrollView
,以允许滚动。
body: SingleChildScrollView(
child: Column(
...