ShowDialog
와 AlertDialog
를 활용하여 팝업 메세지를 구현할 수 있다.
ShowDialog
는 일반적으로 Dialog를 빌드하는데 사용
필수 속성으로 context와 builder를 같는다.
barrierDismissible
은 팝업메세지가 띄워졌을 때 뒷배경의 touchEvent가능 여부에 대한 값이다. fasle로 넣어주면 뒷배경의 touchEvent를 막는다.
AlertDialog
는 사용자에게 승인이 필요한 상황을 알려준다.
onTap: () {
showDialog(
context: context,
builder: (ctx) {
return AlertDialog(
title: const Text('삭제'),
content: const Text('을/를 빼겠습니까?'),
actions: <Widget>[
ElevatedButton(
onPressed: () {
return Navigator.of(context).pop(false);
},
child: const Text('취소'),
),
ElevatedButton(
onPressed: () {
return Navigator.of(context).pop(true);
},
child: const Text('삭제'),
),
],
);
});
},