[英]How can I use checkboxlisttile in alertDialog in flutter?
當我嘗試在警報對話框中使用復選框列表時遇到問題。 我可以看到列表圖塊,但是當我單擊它時它不會改變任何東西,不會有勾號。
bool imp = false
Future _showAlert(BuildContext context) {
return showDialog(
context: context,
child: AlertDialog(
title: Text('Add'),
content: Container(
child: Column(
children: <Widget>[
TextField(),
CheckboxListTile(
title: Text('Important:'),
value: imp,
onChanged: (value) {
setState(() {
imp = value;
});
},
),
],
),
),
),
);
}
只需將這 2 行添加到您的 onchange 方法中
onChanged: (value) {
setState(() {
imp = value;
});
Navigator.of(context).pop(); // Line 1
_showAlert(context) ;// Line 2
},
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.