Daraggeable
클래스는 위젯을 드래그 할 수 있도록 만들어주며 드래그 관련 동작들을 처리할 수 있게 해준다.
child: Draggable(
data: snapshot.data![index].id,
feedback: SizedBox(
height: 200,
width: 200,
child: Round(
child: Util.uint8listToImage(
snapshot.data![index].image),
),
),
childWhenDragging: const SizedBox(
height: 200,
width: 200,
),
child: DeleteAnimation(
child: SizedBox(
height: 200,
width: 200,
child: Round(
child: Util.uint8listToImage(
snapshot.data![index].image),
),
),
),
),
DragTarget
위젯은 드래그 된 위젯이 드롭할 대상이 되는 위젯이다.
이 위젯 위에서 드래그 된 위젯이 드롭되면 전달되는 데이터 값을 처리할 수 있다.
DragTarget(
builder: (context, candidateData, rejectedData) {
return Container(
padding: const EdgeInsets.only(top: 20),
color: Colors.red,
child: const Center(
child: Icon(
Icons.delete,
color: Colors.white,
size: 40,
),
),
);
},
onAccept: (data) {
if (data != null) {
deleteshowDialog(data as int).then((value) {
if (value) {
setState(() {
isDelete = false;
memos = memoProvider.memos();
});
}
});
}
},
),
참조
gh.log