有没有更好的方法来检查#flutter中的左/右拖动?我已经做过了,但有时它有效,有时则无效。
new GestureDetector(
onHorizontalDragEnd: (DragEndDetails details) {
print("Drag Left - AddValue");
setState((){
_value++;
});
if (details.velocity.pixelsPerSecond.dx > -1000.0) {
print("Drag Right - SubValue");
setState((){
_value--;
});
}
},
child: new Container(
child:new Text("$_value"),
),
);
details.primaryDelta
而不是details.velocity.pixelsPerSecond.axis
来进行可消除操作。 - Rémi Rousselet