【发布时间】:2021-03-02 23:11:40
【问题描述】:
当长按执行_selectionAlert 时,我有一个列表项,其中有两个按钮,一个用于删除,一个用于编辑(参考图片)。删除工作正常,但是当我按下编辑时,它应该执行_editAlert,它应该显示另一个 alertDialog 但是当我点击它时什么也没发生这里有什么问题?
这负责在_selectionAlert中显示警报对话框
TextButton( // refer code bellow
child: Text('Edit', style: TextStyle(color: Colors.grey)),
onPressed: (){
_editAlert();
Navigator.of(context).pop();
},
)
当项目被长按时运行下面的代码:
void _selectionAlert(){
var selItem = AlertDialog(
title: Text('What you want to do?'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextButton( // ignore this it is for deletion this works fine
child: Text('Delete', style: TextStyle(color: Colors.red)),
onPressed: (){
_deleteItem();
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Edit', style: TextStyle(color: Colors.grey)),
onPressed: (){
_editAlert(); // this line should call _editAlert
Navigator.of(context).pop();
},
)
],
),
);
showDialog(
context: context,
builder: (BuildContext context){
return selItem;
}
);
}
void _editAlert(){ // edit alertDialog
var editItem = AlertDialog(
title: Text('Edit'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
decoration: InputDecoration(
hintText: 'Edit Item',
),
controller: addeditem,
),
TextButton(
child: Text('Done'),
onPressed: (){
_editItem();
Navigator.of(context).pop();
}
)
],
),
);
showDialog(
context: context,
builder: (BuildContext context){
return editItem;
}
);
}
PS:编辑按钮是灰色的,该按钮肯定是可点击的,我正在谷歌浏览器上进行测试。
问候
【问题讨论】:
-
我只是想知道我在单击编辑时弹出 _selectionAlert 但如果它打开并且我按下完成时它会在弹出时返回哪里?我认为必须有一种不同的方式来调用另一个 alertdialog 中的 alertdialog
标签: flutter dart button dialog flutter-web