gpt4 book ai didi

flutter - 我在dart中的if语句有问题

转载 作者:行者123 更新时间:2023-12-03 03:00:16 24 4
gpt4 key购买 nike

child: RaisedButton(
onPressed: () {
if (_formKey.currentState.validate()) {
double angle = double.parse(a.text);

print(angle);
if (v.text != null) {
double velocity = double.parse(v.text);
print(velocity);
} else if (h.text != null) {
double height = double.parse(h.text);
print(height);
print(angle);
} else if (t.text != null) {
double time = double.parse(t.text);
print(time);
print(angle);
}
}
},

在下面的代码中,当我将v.text保留为空时,它仍然读取if语句,并且在我验证表单时不会跳转到else if部分。我不知道为什么要这么做,请帮帮我

最佳答案

代替v.text != null
v.text.isNotEmpty

关于flutter - 我在dart中的if语句有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62087285/

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