在扑朔迷离/飞镖中满足条件时,如何执行功能?
我有一个功能:
//Alert Dialog about questions and answers
void _showAlertDialog() {
// set up the buttons
Widget Answer1Button = TextButton(
child: Text(_listData[_listCount][3]),
onPressed: () {},
);
Widget Answer2Button = TextButton(
child: Text(_listData[_listCount][4]),
onPressed: () {},
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
// title: Text(),
content: Text(_listData[_listCount][2]),
actions: [
Answer1Button,
Answer2Button,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
当我单击不同位置进行测试的按钮时,它可以很好地工作。但是如何使其在以下条件下运行:
void _nextCSV() {
setState(() {
_listData = _listData;
_listData[_listCount][2] == "" ? _showAlertDialog : print('False');
});
}
谢谢。
I have a function:
//Alert Dialog about questions and answers
void _showAlertDialog() {
// set up the buttons
Widget Answer1Button = TextButton(
child: Text(_listData[_listCount][3]),
onPressed: () {},
);
Widget Answer2Button = TextButton(
child: Text(_listData[_listCount][4]),
onPressed: () {},
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
// title: Text(),
content: Text(_listData[_listCount][2]),
actions: [
Answer1Button,
Answer2Button,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
It works great when I click on the button in the different place for testing. But how to make it run under the following condition:
void _nextCSV() {
setState(() {
_listData = _listData;
_listData[_listCount][2] == "" ? _showAlertDialog : print('False');
});
}
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少
()
,但是即使在
setState
内,也可以使用,以防。编辑:
如果您要忽略然后或 else 块,则可以放置
null
。You are missing the
()
But even inside the
setState
you can useif
in case you want to.Edited:
In case you want to ignore the then or the else block you could just put
null
.