【发布时间】:2020-10-17 23:35:33
【问题描述】:
Flutter 我只需要在按下按钮时隐藏我的组件,因此我设置了布尔值并使用 if 条件,但问题是它显示错误列子项不得包含空值。
这是我的代码
Widget build(BuildContext context) {
var first = true;
var second = false;
Size size = MediaQuery.of(context).size;
return Background(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"SIGNUP",
style: TextStyle(fontWeight: FontWeight.bold),
),
SizedBox(height: size.height * 0.03),
SvgPicture.asset(
"assets/icons/signup.svg",
height: size.height * 0.35,
),
first ? RoundedInputField(
hintText: "Your Name",
icon: Icons.person,
onChanged: (value) {},
) : null ,
first ? RoundedInputField(
hintText: "Your Email",
icon: Icons.mail,
onChanged: (value) {
print(value);
},
) : null ,
first ? RoundedPasswordField(
onChanged: (value) {},
) : null ,
second ? RoundedInputField(
hintText: "Your Number",
icon: Icons.phone,
onChanged: (value) {
print(value);
},
) : null ,
first ? RoundedButton(
text: "NEXT",
press: () {
first = false;
second = true;
},
) : null ,
second ? RoundedButton(
text: "REGISTER",
press: () {
},
) : null ,
SizedBox(height: size.height * 0.03),
AlreadyHaveAnAccountCheck(
login: false,
press: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return LoginScreen();
},
),
);
},
),
],
),
),
);
}
}
我只是在点击时隐藏我的输入小部件,点击后需要显示其他输入和按钮。但是得到错误列子级不能包含任何空值
【问题讨论】:
标签: flutter