【发布时间】:2021-08-01 04:53:14
【问题描述】:
我无法在表单上滚动,如何解决滚动问题:代码和错误如下。
来自终端的错误: ════════ 渲染库捕获的异常════════════════════════════════ 在布局期间抛出了以下断言: 一个 RenderFlex 在底部溢出了 179 像素。
相关的导致错误的小部件是 柱子 lib\auth\signupBasicDetails.dart:254 溢出的 RenderFlex 具有 Axis.vertical 的方向。 溢出的 RenderFlex 边缘已在渲染中用黄色和黑色条纹图案标记。这通常是由于内容对于 RenderFlex 而言太大。
考虑应用 flex 因子(例如,使用 Expanded 小部件)来强制 RenderFlex 的子级适应可用空间,而不是调整到其自然大小。 这被认为是一种错误情况,因为它表明存在看不到的内容。如果内容合法地大于可用空间,请考虑在将其放入 flex 之前使用 ClipRect 小部件对其进行剪辑,或者使用可滚动容器而不是 Flex,例如 ListView。
有问题的具体 RenderFlex 是:RenderFlex#d8c43 relayoutBoundary=up2 OVERFLOWING
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
body: Container(
width: MediaQuery.of(context).size.width,
//color: Colors.red,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
// padding: EdgeInsets.all(10),
padding: EdgeInsets.only(left: 20, top: 60),
child: GestureDetector(
onTap: () {
if (pageController.page == 0) {
Navigator.pop(context);
} else {
setState(() {
if (fourthPage) {
nextButtonText = "Next";
fourthPage = false;
} else if (thirdPage) {
thirdPage = false;
} else if (secondPage) {
secondPage = false;
}
});
pageController.previousPage(
duration: Duration(milliseconds: 200),
curve: Curves.easeIn);
}
},
child: Icon(
Icons.arrow_back,
),
),
),
SizedBox(
height: 0.5,
),
Container(
alignment: Alignment.topCenter,
height: 130,
child: Image.asset(
'images/1.jpg',
fit: BoxFit.contain,
),
),
Container(
alignment: Alignment.topCenter,
child: Text("App",
style: TextStyle(
fontFamily: "Source Sans Pro Regular",
color: Colors.black,
fontSize: 40,
)),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 15,
width: 15,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: redColor,
border: Border.all(color:redColor)),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: Text(
"-",
style: TextStyle(
fontFamily: "Montserrat Regular",
fontSize: 22,
color:
secondPage ? redColor : greyColor),
),
),
Container(
height: 15,
width: 15,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: secondPage ? redColor : Colors.white,
border: Border.all(
color: secondPage
? redColor
: greyColor)),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: Text(
"-",
style: TextStyle(
fontFamily: "Montserrat Regular",
fontSize: 22,
color:
thirdPage ? redColor : greyColor),
),
),
Container(
height: 15,
width: 15,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: thirdPage ? redColor : Colors.white,
border: Border.all(
color: thirdPage
? redColor
: greyColor)),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: Text(
"-",
style: TextStyle(
fontFamily: "Montserrat Regular",
fontSize: 22,
color:
fourthPage ? redColor : greyColor),
),
),
Container(
height: 15,
width: 15,
decoration: BoxDecoration(
color: fourthPage ? redColor : Colors.white,
shape: BoxShape.circle,
border: Border.all(
color: fourthPage
? redColor
: greyColor)),
),
],
),
),
SizedBox(
height: 10,
),
Container(
height: 380,
child: PageView(
physics: NeverScrollableScrollPhysics(),
controller: pageController,
children: [
FirstPageSignUp(),
SecondPageSignUp(),
ThirdPageSignUp(),
FourthPageSignUp()
],
),
),
SizedBox(
height: 1,
),
Center(
child: FlatButton(
color: Color(0xffD21F3C),
onPressed: () {
setState(() {
if (pageController.page == 0 &&
_formkey1.currentState.validate()) {
....
} else if (pageController.page == 1 &&
_formkey2.currentState.validate()) {
...
} else if (pageController.page == 2 &&
_formkey3.currentState.validate()) {
...
} else if (pageController.page == 3 &&
_formkey4.currentState.validate()) {
...
if (vendordropdown == "...") {
...
} else if (vendordropdown == "...") {
...
} else if (vendordropdown == "...") {
...
}
attemptSignUp(
....);
}
});
},
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(4),
side: BorderSide(color: Color(0xffD21F3C))),
textColor: Colors.white,
child: Container(
height: 45,
width: 200,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
nextButtonText,
style: new TextStyle(
color: Colors.white,
fontFamily: "Montserrat SemiBold",
fontSize: 18),
),
Icon(Icons.arrow_forward, color: Colors.white)
],
)),
),
),
],
),
),
);
} }
【问题讨论】: