gpt4 book ai didi

flutter - 键盘背景和 SingleChildScrollView 问题

转载 作者:IT王子 更新时间:2023-10-29 07:02:07 28 4
gpt4 key购买 nike

每次我打开键盘时,图像都会根据键盘上方的屏幕尺寸进行缩放,而不是在设备的整个屏幕上。我的代码如下,请问如何解决?因为如果我不放置 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),
),
),
)
],
),
),
);
},
),
),
);
}
}

最佳答案

在您的代码中,您需要在 Scaffold 中添加 - resizeToAvoidBottomPadding: false,

代码:

.....
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomPadding: false, /// Add this
body: Container(
.....

关于flutter - 键盘背景和 SingleChildScrollView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57438721/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com