gpt4 book ai didi

flutter - 如何在复选框上显示AlertDialog单击

转载 作者:行者123 更新时间:2023-12-03 04:49:05 25 4
gpt4 key购买 nike

单击AlertDialog后如何显示弹出窗口或Checkbox。我在onPressed中找不到类似CheckBox的东西。

最佳答案

Checkbox确实具有onChanged回调,该回调返回当前检查状态的值,简短示例:

bool _checked = false;

@override
Widget build(BuildContext context) {
return Scaffold(
body: Checkbox(
value: _checked,
onChanged: (checked) {
setState(() => _checked = checked);
if (_checked) {
// show dialog if check box is checked
showDialog(context: context, builder: (_) => AlertDialog(title: Text("Dialog")));
}
},
),
);
}

关于flutter - 如何在复选框上显示AlertDialog单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61712513/

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