Flutter - Ges手势初使用(拖拽方块跟随鼠标移动)

class GesTest extends StatefulWidget {

@override

  _GesTestState createState() =>_GesTestState();

}

class _GesTestState extends State {

double_top =0.0;

double_left =0.0;

@override

  Widget build(BuildContext context) {

return Stack(

children: [

Positioned(

left:_left,

top:_top,

child:GestureDetector(

onPanUpdate: (e){

setState(() {

_left =_left + e.delta.dx;

_top =_top + e.delta.dy;

});

},

child:Container(

color: Colors.red,width:100,height:100,

),

)

)

],

);

}

}

你可能感兴趣的:(Flutter - Ges手势初使用(拖拽方块跟随鼠标移动))