Draggable class - widgets library - Dart API
Stateful 위젯이며 해당값들을 변환시킬때 유용하다.
ex)장바구니 담기/쓰레기통으로 이동 등과같은 단순하게 사용할수있지만 유용한것들
Flutter docs 찾아보면 재밌는 class가 많은것같다.
Row(children: [
Draggable<int>(
// Data is the value this Draggable stores.
data: 50,
feedback: Container(
color: Colors.blue,
height: 100,
width: 100,
child: const Icon(Icons.directions_run),
),
childWhenDragging: Container(
height: 100.0,
width: 100.0,
color: Colors.pinkAccent,
child: const Center(
child: Text('이동중'),
),
),
child: Container(
height: 100.0,
width: 100.0,
color: Colors.lightGreenAccent,
child: const Center(
child: Text('추가하기'),
),
),
),
const Spacer(),
DragTarget<int>(
builder: (
BuildContext context,
List<dynamic> accepted,
List<dynamic> rejected,
) {
return Container(
height: 100.0,
width: 100.0,
color: Colors.cyan,
child: Center(
child: Text('현재 값: ${free}!'),
),
);
},
onAccept: (int data) {
setState(() {
free += data;
});
},
)
]),
해당 위젯을 드래그하여 이동할경우 data값만큼 증가하는것이다.