问题
I have a ternary operator in my home_screen:
CircleData2.dk1 == 0 ? Padding(child: Center(child: Container(height: 50, width: 50, color: Colors.pink,)), padding: EdgeInsets.all(40),) : Try2(id: 1, reload: reload,),
I want when CircleData.dk1 not equals 0 (it starts off equaling 1) to drop the current object that's dragging (Try2 is a custom widget that is a draggable, I'll show it in a moment) and just replace it with the:
Padding(child: Center(child: Container(height: 50, width: 50, color: Colors.pink,)), padding: EdgeInsets.all(40),)
The Custom Try2 widget is as follows:
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(40),
child: Center(
child: DragTarget<dynamic>(
builder: (context, accepted, rejected){
return Draggable(
maxSimultaneousDrags: getDrag(),
child: Container(height: 50, width: 50, color: Colors.pink,),
feedback: Container(height: 50, width: 50, color: Colors.pink,),
childWhenDragging: Container(height: 50, width: 50, color: Colors.yellowAccent,),
);
}
),
),
);
}
来源:https://stackoverflow.com/questions/62012644/anyway-to-cancel-currently-dragging-widget-in-flutter