每次我打开键盘时,图像都会根据键盘上方的屏幕尺寸缩放,而不是根据设备的整个屏幕缩放。我的代码如下,我该如何解决?因为如果我不放SingleChieldScrollView,它将显示黄色像素警报横幅。
每次我打开键盘时,图像都会根据键盘上方的屏幕尺寸缩放,而不是根据设备的整个屏幕缩放。我的代码如下,我该如何解决?因为如果我不放SingleChieldScrollView,它将显示黄色像素警报横幅。
每次我打开键盘时,图像都会根据键盘上方的屏幕尺寸缩放,而不是根据设备的整个屏幕缩放。我的代码如下,我该如何解决?因为如果我不放SingleChieldScrollView,它将显示黄色像素警报横幅。
import 'package:flutter/material.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("imgs/bgLogin.jpg"), fit: BoxFit.cover)),
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
child: Column(
children: <Widget>[
Text("Bem Vindo ao,", style: TextStyle(fontSize: 32)),
Text("MedPAD", style: TextStyle(fontSize: 52))
],
),
),
Container(
padding: EdgeInsets.only(
left: 15.0, right: 15.0, top: 50.0, bottom: 5.0),
child: TextField(
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
labelText: "E-Mail", border: OutlineInputBorder()),
),
),
Container(
padding: EdgeInsets.only(
left: 15.0, right: 15.0, top: 5.0, bottom: 15.0),
child: TextField(
keyboardType: TextInputType.text,
decoration: InputDecoration(
labelText: "Senha", border: OutlineInputBorder()),
),
),
Container(
padding: EdgeInsets.only(
left: 15.0, right: 15.0, top: 5.0, bottom: 15.0),
child: TextField(
keyboardType: TextInputType.text,
decoration: InputDecoration(
labelText: "Senha", border: OutlineInputBorder()),
),
),
Container(
padding: EdgeInsets.only(left: 75.0, right: 75.0),
height: 50.0,
child: RaisedButton(
color: Colors.red,
onPressed: () {},
child: Text(
"Entrar",
style: TextStyle(color: Colors.white),
),
),
)
],
),
),
);
},
),
),
);
}
}
答案 0 :(得分:0)
在代码中,您需要在resizeToAvoidBottomPadding: false,
中添加-Scaffold
代码:
.....
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomPadding: false, /// Add this
body: Container(
.....