DragTarget onWillAccept and onAccept not firing DragTarget onWillAccept and onAccept not firing flutter flutter

DragTarget onWillAccept and onAccept not firing


Apparently the Draggable and DragTarget need to have the generic type specified if you are passing data, otherwise the onAccept and onWillAccept will not be fired.

For example, if you want to pass data as int then use Draggable<int> and DragTarget<int> — this also applies to onAccept and onWillAccept, they need to accept int as a parameter.


You should setState when you call onAccept and add a boolean value to your stateful widget.

bool accepted = false;

onAccept: (data){      if(data=='d'){        setState(() {          accepted = true;        });      },