Anyway to cancel currently dragging widget in flutter?

不打扰是莪最后的温柔 提交于 2021-01-29 05:41:54

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!