mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Convert drag gestures to use details objects (#4343)
Previously we supplied individual parameters to the various drag and pan callbacks. However, that approach isn't extensible because each new parameter is a breaking change to the API. This patch makes a one-time breaking change to the API to provide a "details" object that we can extend over time as we need to expose more information. The first planned extension is adding enough information to accurately produce an overscroll glow on Android.
This commit is contained in:
parent
5245d3889d
commit
2d4acb8041
@ -48,7 +48,7 @@ class WindowDecoration extends StatelessWidget {
|
|||||||
final WindowSide side;
|
final WindowSide side;
|
||||||
final Color color;
|
final Color color;
|
||||||
final GestureTapCallback onTap;
|
final GestureTapCallback onTap;
|
||||||
final GesturePanUpdateCallback onPanUpdate;
|
final GestureDragUpdateCallback onPanUpdate;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -106,18 +106,18 @@ class _WindowState extends State<Window> {
|
|||||||
Offset _offset = Offset.zero;
|
Offset _offset = Offset.zero;
|
||||||
Size _size = _kInitialWindowSize;
|
Size _size = _kInitialWindowSize;
|
||||||
|
|
||||||
void _handleResizerDrag(Offset delta) {
|
void _handleResizerDrag(DragUpdateDetails details) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_size = new Size(
|
_size = new Size(
|
||||||
math.max(0.0, _size.width + delta.dx),
|
math.max(0.0, _size.width + details.delta.dx),
|
||||||
math.max(0.0, _size.height + delta.dy)
|
math.max(0.0, _size.height + details.delta.dy)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleRepositionDrag(Offset delta) {
|
void _handleRepositionDrag(DragUpdateDetails details) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_offset += delta;
|
_offset += details.delta;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,52 +14,97 @@ enum _DragState {
|
|||||||
accepted,
|
accepted,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Details for [GestureDragDownCallback].
|
||||||
|
class DragDownDetails {
|
||||||
|
/// Creates details for a [GestureDragDownCallback].
|
||||||
|
///
|
||||||
|
/// The [globalPosition] argument must not be null.
|
||||||
|
DragDownDetails({ this.globalPosition: Point.origin }) {
|
||||||
|
assert(globalPosition != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The global position at which the pointer contacted the screen.
|
||||||
|
final Point globalPosition;
|
||||||
|
}
|
||||||
|
|
||||||
/// Signature for when a pointer has contacted the screen and might begin to move.
|
/// Signature for when a pointer has contacted the screen and might begin to move.
|
||||||
typedef void GestureDragDownCallback(Point globalPosition);
|
typedef void GestureDragDownCallback(DragDownDetails details);
|
||||||
|
|
||||||
|
/// Details for [GestureDragStartCallback].
|
||||||
|
class DragStartDetails {
|
||||||
|
/// Creates details for a [GestureDragStartCallback].
|
||||||
|
///
|
||||||
|
/// The [globalPosition] argument must not be null.
|
||||||
|
DragStartDetails({ this.globalPosition: Point.origin }) {
|
||||||
|
assert(globalPosition != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The global position at which the pointer contacted the screen.
|
||||||
|
final Point globalPosition;
|
||||||
|
}
|
||||||
|
|
||||||
/// Signature for when a pointer has contacted the screen and has begun to move.
|
/// Signature for when a pointer has contacted the screen and has begun to move.
|
||||||
typedef void GestureDragStartCallback(Point globalPosition);
|
typedef void GestureDragStartCallback(DragStartDetails details);
|
||||||
|
|
||||||
|
/// Details for [GestureDragUpdateCallback].
|
||||||
|
class DragUpdateDetails {
|
||||||
|
/// Creates details for a [DragUpdateDetails].
|
||||||
|
///
|
||||||
|
/// The [delta] argument must not be null.
|
||||||
|
///
|
||||||
|
/// If [primaryDelta] is non-null, then its value must match one of the
|
||||||
|
/// coordinates of [delta] and the other coordinate must be zero.
|
||||||
|
DragUpdateDetails({
|
||||||
|
this.delta: Offset.zero,
|
||||||
|
this.primaryDelta: 0.0
|
||||||
|
}) {
|
||||||
|
assert(primaryDelta == null
|
||||||
|
|| (primaryDelta == delta.dx && delta.dy == 0.0)
|
||||||
|
|| (primaryDelta == delta.dy && delta.dx == 0.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The amount the pointer has moved since the previous update.
|
||||||
|
///
|
||||||
|
/// If the [GestureDragUpdateCallback] is for a one-dimensional drag (e.g.,
|
||||||
|
/// a horizontal or vertical drag), then this offset contains only the delta
|
||||||
|
/// in that direction (i.e., the coordinate in the other direction is zero).
|
||||||
|
final Offset delta;
|
||||||
|
|
||||||
|
/// The amount the pointer has moved along the primary axis since the previous
|
||||||
|
/// update.
|
||||||
|
///
|
||||||
|
/// If the [GestureDragUpdateCallback] is for a one-dimensional drag (e.g.,
|
||||||
|
/// a horizontal or vertical drag), then this value contains the non-zero
|
||||||
|
/// component of [delta]. Otherwise, if the [GestureDragUpdateCallback] is for
|
||||||
|
/// a two-dimensional drag (e.g., a pan), then this value is zero.
|
||||||
|
final double primaryDelta;
|
||||||
|
}
|
||||||
|
|
||||||
/// Signature for when a pointer that is in contact with the screen and moving
|
/// Signature for when a pointer that is in contact with the screen and moving
|
||||||
/// in a direction (e.g., vertically or horizontally) has moved in that
|
/// has moved again.
|
||||||
/// direction.
|
typedef void GestureDragUpdateCallback(DragUpdateDetails details);
|
||||||
typedef void GestureDragUpdateCallback(double delta);
|
|
||||||
|
/// Details for [GestureDragEndCallback].
|
||||||
|
class DragEndDetails {
|
||||||
|
/// Creates details for a [GestureDragEndCallback].
|
||||||
|
///
|
||||||
|
/// The [velocity] argument must not be null.
|
||||||
|
DragEndDetails({ this.velocity: Velocity.zero }) {
|
||||||
|
assert(velocity != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The velocity the pointer was moving when it stopped contacting the screen.
|
||||||
|
final Velocity velocity;
|
||||||
|
}
|
||||||
|
|
||||||
/// Signature for when a pointer that was previously in contact with the screen
|
/// Signature for when a pointer that was previously in contact with the screen
|
||||||
/// and moving in a direction (e.g., vertically or horizontally) is no longer in
|
/// and moving is no longer in contact with the screen.
|
||||||
/// contact with the screen and was moving at a specific velocity when it
|
typedef void GestureDragEndCallback(DragEndDetails details);
|
||||||
/// stopped contacting the screen.
|
|
||||||
typedef void GestureDragEndCallback(Velocity velocity);
|
|
||||||
|
|
||||||
/// Signature for when the pointer that previously triggered a
|
/// Signature for when the pointer that previously triggered a
|
||||||
/// [GestureDragDownCallback] did not complete.
|
/// [GestureDragDownCallback] did not complete.
|
||||||
typedef void GestureDragCancelCallback();
|
typedef void GestureDragCancelCallback();
|
||||||
|
|
||||||
/// Signature for when a pointer has contacted the screen and might begin to move.
|
|
||||||
typedef void GesturePanDownCallback(Point globalPosition);
|
|
||||||
|
|
||||||
/// Signature for when a pointer has contacted the screen and has begun to move.
|
|
||||||
typedef void GesturePanStartCallback(Point globalPosition);
|
|
||||||
|
|
||||||
/// Signature for when a pointer that is in contact with the screen and moving
|
|
||||||
/// has moved again.
|
|
||||||
typedef void GesturePanUpdateCallback(Offset delta);
|
|
||||||
|
|
||||||
/// Signature for when a pointer that was previously in contact with the screen
|
|
||||||
/// and moving is no longer in contact with the screen and was moving at a
|
|
||||||
/// specific velocity when it stopped contacting the screen.
|
|
||||||
typedef void GesturePanEndCallback(Velocity velocity);
|
|
||||||
|
|
||||||
/// Signature for when the pointer that previously triggered a
|
|
||||||
/// [GesturePanDownCallback] did not complete.
|
|
||||||
typedef void GesturePanCancelCallback();
|
|
||||||
|
|
||||||
/// Signature for when a pointer that is in contact with the screen and moving
|
|
||||||
/// has moved again. For one-dimensional drags (e.g., horizontal or vertical),
|
|
||||||
/// T is `double`, as in [GestureDragUpdateCallback]. For two-dimensional drags
|
|
||||||
/// (e.g., pans), T is `Offset`, as in GesturePanUpdateCallback.
|
|
||||||
typedef void GesturePolymorphicUpdateCallback<T>(T delta);
|
|
||||||
|
|
||||||
bool _isFlingGesture(Velocity velocity) {
|
bool _isFlingGesture(Velocity velocity) {
|
||||||
assert(velocity != null);
|
assert(velocity != null);
|
||||||
final double speedSquared = velocity.pixelsPerSecond.distanceSquared;
|
final double speedSquared = velocity.pixelsPerSecond.distanceSquared;
|
||||||
@ -82,9 +127,7 @@ bool _isFlingGesture(Velocity velocity) {
|
|||||||
/// * [HorizontalDragGestureRecognizer]
|
/// * [HorizontalDragGestureRecognizer]
|
||||||
/// * [VerticalDragGestureRecognizer]
|
/// * [VerticalDragGestureRecognizer]
|
||||||
/// * [PanGestureRecognizer]
|
/// * [PanGestureRecognizer]
|
||||||
// Having T extend dynamic makes it possible to use the += operator on
|
abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||||
// _pendingDragDelta without causing an analysis error.
|
|
||||||
abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestureRecognizer {
|
|
||||||
/// A pointer has contacted the screen and might begin to move.
|
/// A pointer has contacted the screen and might begin to move.
|
||||||
GestureDragDownCallback onDown;
|
GestureDragDownCallback onDown;
|
||||||
|
|
||||||
@ -92,7 +135,7 @@ abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestu
|
|||||||
GestureDragStartCallback onStart;
|
GestureDragStartCallback onStart;
|
||||||
|
|
||||||
/// A pointer that is in contact with the screen and moving has moved again.
|
/// A pointer that is in contact with the screen and moving has moved again.
|
||||||
GesturePolymorphicUpdateCallback<T> onUpdate;
|
GestureDragUpdateCallback onUpdate;
|
||||||
|
|
||||||
/// A pointer that was previously in contact with the screen and moving is no
|
/// A pointer that was previously in contact with the screen and moving is no
|
||||||
/// longer in contact with the screen and was moving at a specific velocity
|
/// longer in contact with the screen and was moving at a specific velocity
|
||||||
@ -104,10 +147,10 @@ abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestu
|
|||||||
|
|
||||||
_DragState _state = _DragState.ready;
|
_DragState _state = _DragState.ready;
|
||||||
Point _initialPosition;
|
Point _initialPosition;
|
||||||
T _pendingDragDelta;
|
Offset _pendingDragOffset;
|
||||||
|
|
||||||
T get _initialPendingDragDelta;
|
Offset _getDeltaForDetails(Offset delta);
|
||||||
T _getDragDelta(PointerEvent event);
|
double _getPrimaryDeltaForDetails(Offset delta);
|
||||||
bool get _hasSufficientPendingDragDeltaToAccept;
|
bool get _hasSufficientPendingDragDeltaToAccept;
|
||||||
|
|
||||||
Map<int, VelocityTracker> _velocityTrackers = new Map<int, VelocityTracker>();
|
Map<int, VelocityTracker> _velocityTrackers = new Map<int, VelocityTracker>();
|
||||||
@ -119,9 +162,9 @@ abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestu
|
|||||||
if (_state == _DragState.ready) {
|
if (_state == _DragState.ready) {
|
||||||
_state = _DragState.possible;
|
_state = _DragState.possible;
|
||||||
_initialPosition = event.position;
|
_initialPosition = event.position;
|
||||||
_pendingDragDelta = _initialPendingDragDelta;
|
_pendingDragOffset = Offset.zero;
|
||||||
if (onDown != null)
|
if (onDown != null)
|
||||||
onDown(_initialPosition);
|
onDown(new DragDownDetails(globalPosition: _initialPosition));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,12 +175,16 @@ abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestu
|
|||||||
VelocityTracker tracker = _velocityTrackers[event.pointer];
|
VelocityTracker tracker = _velocityTrackers[event.pointer];
|
||||||
assert(tracker != null);
|
assert(tracker != null);
|
||||||
tracker.addPosition(event.timeStamp, event.position);
|
tracker.addPosition(event.timeStamp, event.position);
|
||||||
T delta = _getDragDelta(event);
|
Offset delta = event.delta;
|
||||||
if (_state == _DragState.accepted) {
|
if (_state == _DragState.accepted) {
|
||||||
if (onUpdate != null)
|
if (onUpdate != null) {
|
||||||
onUpdate(delta);
|
onUpdate(new DragUpdateDetails(
|
||||||
|
delta: _getDeltaForDetails(delta),
|
||||||
|
primaryDelta: _getPrimaryDeltaForDetails(delta)
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_pendingDragDelta += delta;
|
_pendingDragOffset += delta;
|
||||||
if (_hasSufficientPendingDragDeltaToAccept)
|
if (_hasSufficientPendingDragDeltaToAccept)
|
||||||
resolve(GestureDisposition.accepted);
|
resolve(GestureDisposition.accepted);
|
||||||
}
|
}
|
||||||
@ -149,12 +196,16 @@ abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestu
|
|||||||
void acceptGesture(int pointer) {
|
void acceptGesture(int pointer) {
|
||||||
if (_state != _DragState.accepted) {
|
if (_state != _DragState.accepted) {
|
||||||
_state = _DragState.accepted;
|
_state = _DragState.accepted;
|
||||||
T delta = _pendingDragDelta;
|
Offset delta = _pendingDragOffset;
|
||||||
_pendingDragDelta = _initialPendingDragDelta;
|
_pendingDragOffset = Offset.zero;
|
||||||
if (onStart != null)
|
if (onStart != null)
|
||||||
onStart(_initialPosition);
|
onStart(new DragStartDetails(globalPosition: _initialPosition));
|
||||||
if (delta != _initialPendingDragDelta && onUpdate != null)
|
if (delta != Offset.zero && onUpdate != null) {
|
||||||
onUpdate(delta);
|
onUpdate(new DragUpdateDetails(
|
||||||
|
delta: _getDeltaForDetails(delta),
|
||||||
|
primaryDelta: _getPrimaryDeltaForDetails(delta)
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,9 +234,9 @@ abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestu
|
|||||||
final Offset pixelsPerSecond = velocity.pixelsPerSecond;
|
final Offset pixelsPerSecond = velocity.pixelsPerSecond;
|
||||||
if (pixelsPerSecond.distanceSquared > kMaxFlingVelocity * kMaxFlingVelocity)
|
if (pixelsPerSecond.distanceSquared > kMaxFlingVelocity * kMaxFlingVelocity)
|
||||||
velocity = new Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity);
|
velocity = new Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity);
|
||||||
onEnd(velocity);
|
onEnd(new DragEndDetails(velocity: velocity));
|
||||||
} else {
|
} else {
|
||||||
onEnd(Velocity.zero);
|
onEnd(new DragEndDetails(velocity: Velocity.zero));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_velocityTrackers.clear();
|
_velocityTrackers.clear();
|
||||||
@ -205,15 +256,15 @@ abstract class DragGestureRecognizer<T extends dynamic> extends OneSequenceGestu
|
|||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [VerticalMultiDragGestureRecognizer]
|
/// * [VerticalMultiDragGestureRecognizer]
|
||||||
class VerticalDragGestureRecognizer extends DragGestureRecognizer<double> {
|
class VerticalDragGestureRecognizer extends DragGestureRecognizer {
|
||||||
@override
|
@override
|
||||||
double get _initialPendingDragDelta => 0.0;
|
bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragOffset.dy.abs() > kTouchSlop;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
double _getDragDelta(PointerEvent event) => event.delta.dy;
|
Offset _getDeltaForDetails(Offset delta) => new Offset(0.0, delta.dy);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragDelta.abs() > kTouchSlop;
|
double _getPrimaryDeltaForDetails(Offset delta) => delta.dy;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toStringShort() => 'vertical drag';
|
String toStringShort() => 'vertical drag';
|
||||||
@ -226,15 +277,15 @@ class VerticalDragGestureRecognizer extends DragGestureRecognizer<double> {
|
|||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [HorizontalMultiDragGestureRecognizer]
|
/// * [HorizontalMultiDragGestureRecognizer]
|
||||||
class HorizontalDragGestureRecognizer extends DragGestureRecognizer<double> {
|
class HorizontalDragGestureRecognizer extends DragGestureRecognizer {
|
||||||
@override
|
@override
|
||||||
double get _initialPendingDragDelta => 0.0;
|
bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragOffset.dx.abs() > kTouchSlop;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
double _getDragDelta(PointerEvent event) => event.delta.dx;
|
Offset _getDeltaForDetails(Offset delta) => new Offset(delta.dx, 0.0);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragDelta.abs() > kTouchSlop;
|
double _getPrimaryDeltaForDetails(Offset delta) => delta.dx;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toStringShort() => 'horizontal drag';
|
String toStringShort() => 'horizontal drag';
|
||||||
@ -246,18 +297,18 @@ class HorizontalDragGestureRecognizer extends DragGestureRecognizer<double> {
|
|||||||
///
|
///
|
||||||
/// * [ImmediateMultiDragGestureRecognizer]
|
/// * [ImmediateMultiDragGestureRecognizer]
|
||||||
/// * [DelayedMultiDragGestureRecognizer]
|
/// * [DelayedMultiDragGestureRecognizer]
|
||||||
class PanGestureRecognizer extends DragGestureRecognizer<Offset> {
|
class PanGestureRecognizer extends DragGestureRecognizer {
|
||||||
@override
|
|
||||||
Offset get _initialPendingDragDelta => Offset.zero;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Offset _getDragDelta(PointerEvent event) => event.delta;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get _hasSufficientPendingDragDeltaToAccept {
|
bool get _hasSufficientPendingDragDeltaToAccept {
|
||||||
return _pendingDragDelta.distance > kPanSlop;
|
return _pendingDragOffset.distance > kPanSlop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Offset _getDeltaForDetails(Offset delta) => delta;
|
||||||
|
|
||||||
|
@override
|
||||||
|
double _getPrimaryDeltaForDetails(Offset delta) => null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toStringShort() => 'pan';
|
String toStringShort() => 'pan';
|
||||||
}
|
}
|
||||||
|
@ -97,17 +97,17 @@ class _BottomSheetState extends State<BottomSheet> {
|
|||||||
|
|
||||||
bool get _dismissUnderway => config.animationController.status == AnimationStatus.reverse;
|
bool get _dismissUnderway => config.animationController.status == AnimationStatus.reverse;
|
||||||
|
|
||||||
void _handleDragUpdate(double delta) {
|
void _handleDragUpdate(DragUpdateDetails details) {
|
||||||
if (_dismissUnderway)
|
if (_dismissUnderway)
|
||||||
return;
|
return;
|
||||||
config.animationController.value -= delta / (_childHeight ?? delta);
|
config.animationController.value -= details.primaryDelta / (_childHeight ?? details.primaryDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragEnd(Velocity velocity) {
|
void _handleDragEnd(DragEndDetails details) {
|
||||||
if (_dismissUnderway)
|
if (_dismissUnderway)
|
||||||
return;
|
return;
|
||||||
if (velocity.pixelsPerSecond.dy > _kMinFlingVelocity) {
|
if (details.velocity.pixelsPerSecond.dy > _kMinFlingVelocity) {
|
||||||
double flingVelocity = -velocity.pixelsPerSecond.dy / _childHeight;
|
double flingVelocity = -details.velocity.pixelsPerSecond.dy / _childHeight;
|
||||||
config.animationController.fling(velocity: flingVelocity);
|
config.animationController.fling(velocity: flingVelocity);
|
||||||
if (flingVelocity < 0.0)
|
if (flingVelocity < 0.0)
|
||||||
config.onClosing();
|
config.onClosing();
|
||||||
|
@ -173,7 +173,7 @@ class DrawerControllerState extends State<DrawerController> {
|
|||||||
|
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
|
|
||||||
void _handleDragDown(Point position) {
|
void _handleDragDown(DragDownDetails details) {
|
||||||
_controller.stop();
|
_controller.stop();
|
||||||
_ensureHistoryEntry();
|
_ensureHistoryEntry();
|
||||||
}
|
}
|
||||||
@ -195,15 +195,15 @@ class DrawerControllerState extends State<DrawerController> {
|
|||||||
return _kWidth; // drawer not being shown currently
|
return _kWidth; // drawer not being shown currently
|
||||||
}
|
}
|
||||||
|
|
||||||
void _move(double delta) {
|
void _move(DragUpdateDetails details) {
|
||||||
_controller.value += delta / _width;
|
_controller.value += details.primaryDelta / _width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _settle(Velocity velocity) {
|
void _settle(DragEndDetails details) {
|
||||||
if (_controller.isDismissed)
|
if (_controller.isDismissed)
|
||||||
return;
|
return;
|
||||||
if (velocity.pixelsPerSecond.dx.abs() >= _kMinFlingVelocity) {
|
if (details.velocity.pixelsPerSecond.dx.abs() >= _kMinFlingVelocity) {
|
||||||
_controller.fling(velocity: velocity.pixelsPerSecond.dx / _width);
|
_controller.fling(velocity: details.velocity.pixelsPerSecond.dx / _width);
|
||||||
} else if (_controller.value < 0.5) {
|
} else if (_controller.value < 0.5) {
|
||||||
close();
|
close();
|
||||||
} else {
|
} else {
|
||||||
|
@ -290,24 +290,24 @@ class _RenderSlider extends RenderConstrainedBox {
|
|||||||
return dragValue;
|
return dragValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragStart(Point globalPosition) {
|
void _handleDragStart(DragStartDetails details) {
|
||||||
if (onChanged != null) {
|
if (onChanged != null) {
|
||||||
_active = true;
|
_active = true;
|
||||||
_currentDragValue = (globalToLocal(globalPosition).x - _kReactionRadius) / _trackLength;
|
_currentDragValue = (globalToLocal(details.globalPosition).x - _kReactionRadius) / _trackLength;
|
||||||
onChanged(_discretizedCurrentDragValue);
|
onChanged(_discretizedCurrentDragValue);
|
||||||
_reactionController.forward();
|
_reactionController.forward();
|
||||||
markNeedsPaint();
|
markNeedsPaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragUpdate(double delta) {
|
void _handleDragUpdate(DragUpdateDetails details) {
|
||||||
if (onChanged != null) {
|
if (onChanged != null) {
|
||||||
_currentDragValue += delta / _trackLength;
|
_currentDragValue += details.primaryDelta / _trackLength;
|
||||||
onChanged(_discretizedCurrentDragValue);
|
onChanged(_discretizedCurrentDragValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragEnd(Velocity velocity) {
|
void _handleDragEnd(DragEndDetails details) {
|
||||||
if (_active) {
|
if (_active) {
|
||||||
_active = false;
|
_active = false;
|
||||||
_currentDragValue = 0.0;
|
_currentDragValue = 0.0;
|
||||||
|
@ -270,21 +270,21 @@ class _RenderSwitch extends RenderToggleable {
|
|||||||
|
|
||||||
HorizontalDragGestureRecognizer _drag;
|
HorizontalDragGestureRecognizer _drag;
|
||||||
|
|
||||||
void _handleDragStart(Point globalPosition) {
|
void _handleDragStart(DragStartDetails details) {
|
||||||
if (onChanged != null)
|
if (onChanged != null)
|
||||||
reactionController.forward();
|
reactionController.forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragUpdate(double delta) {
|
void _handleDragUpdate(DragUpdateDetails details) {
|
||||||
if (onChanged != null) {
|
if (onChanged != null) {
|
||||||
position
|
position
|
||||||
..curve = null
|
..curve = null
|
||||||
..reverseCurve = null;
|
..reverseCurve = null;
|
||||||
positionController.value += delta / _trackInnerLength;
|
positionController.value += details.primaryDelta / _trackInnerLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragEnd(Velocity velocity) {
|
void _handleDragEnd(DragEndDetails details) {
|
||||||
if (position.value >= 0.5)
|
if (position.value >= 0.5)
|
||||||
positionController.forward();
|
positionController.forward();
|
||||||
else
|
else
|
||||||
|
@ -489,24 +489,24 @@ class _DialState extends State<_Dial> {
|
|||||||
Point _position;
|
Point _position;
|
||||||
Point _center;
|
Point _center;
|
||||||
|
|
||||||
void _handlePanStart(Point globalPosition) {
|
void _handlePanStart(DragStartDetails details) {
|
||||||
assert(!_dragging);
|
assert(!_dragging);
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
RenderBox box = context.findRenderObject();
|
RenderBox box = context.findRenderObject();
|
||||||
_position = box.globalToLocal(globalPosition);
|
_position = box.globalToLocal(details.globalPosition);
|
||||||
double radius = box.size.shortestSide / 2.0;
|
double radius = box.size.shortestSide / 2.0;
|
||||||
_center = new Point(radius, radius);
|
_center = new Point(radius, radius);
|
||||||
_updateThetaForPan();
|
_updateThetaForPan();
|
||||||
_notifyOnChangedIfNeeded();
|
_notifyOnChangedIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handlePanUpdate(Offset delta) {
|
void _handlePanUpdate(DragUpdateDetails details) {
|
||||||
_position += delta;
|
_position += details.delta;
|
||||||
_updateThetaForPan();
|
_updateThetaForPan();
|
||||||
_notifyOnChangedIfNeeded();
|
_notifyOnChangedIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handlePanEnd(Velocity velocity) {
|
void _handlePanEnd(DragEndDetails details) {
|
||||||
assert(_dragging);
|
assert(_dragging);
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
_position = null;
|
_position = null;
|
||||||
|
@ -2102,26 +2102,42 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticAc
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void handleSemanticScrollLeft() {
|
void handleSemanticScrollLeft() {
|
||||||
if (onHorizontalDragUpdate != null)
|
if (onHorizontalDragUpdate != null) {
|
||||||
onHorizontalDragUpdate(size.width * -scrollFactor);
|
final double primaryDelta = size.width * -scrollFactor;
|
||||||
|
onHorizontalDragUpdate(new DragUpdateDetails(
|
||||||
|
delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleSemanticScrollRight() {
|
void handleSemanticScrollRight() {
|
||||||
if (onHorizontalDragUpdate != null)
|
if (onHorizontalDragUpdate != null) {
|
||||||
onHorizontalDragUpdate(size.width * scrollFactor);
|
final double primaryDelta = size.width * scrollFactor;
|
||||||
|
onHorizontalDragUpdate(new DragUpdateDetails(
|
||||||
|
delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleSemanticScrollUp() {
|
void handleSemanticScrollUp() {
|
||||||
if (onVerticalDragUpdate != null)
|
if (onVerticalDragUpdate != null) {
|
||||||
onVerticalDragUpdate(size.height * -scrollFactor);
|
final double primaryDelta = size.height * -scrollFactor;
|
||||||
|
onVerticalDragUpdate(new DragUpdateDetails(
|
||||||
|
delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void handleSemanticScrollDown() {
|
void handleSemanticScrollDown() {
|
||||||
if (onVerticalDragUpdate != null)
|
if (onVerticalDragUpdate != null) {
|
||||||
onVerticalDragUpdate(size.height * scrollFactor);
|
final double primaryDelta = size.height * scrollFactor;
|
||||||
|
onVerticalDragUpdate(new DragUpdateDetails(
|
||||||
|
delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ class _DismissableState extends State<Dismissable> {
|
|||||||
return box.size;
|
return box.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragStart(_) {
|
void _handleDragStart(DragStartDetails details) {
|
||||||
_dragUnderway = true;
|
_dragUnderway = true;
|
||||||
if (_moveController.isAnimating) {
|
if (_moveController.isAnimating) {
|
||||||
_dragExtent = _moveController.value * _findSize().width * _dragExtent.sign;
|
_dragExtent = _moveController.value * _findSize().width * _dragExtent.sign;
|
||||||
@ -165,11 +165,12 @@ class _DismissableState extends State<Dismissable> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragUpdate(double delta) {
|
void _handleDragUpdate(DragUpdateDetails details) {
|
||||||
if (!_isActive || _moveController.isAnimating)
|
if (!_isActive || _moveController.isAnimating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double oldDragExtent = _dragExtent;
|
final double delta = details.primaryDelta;
|
||||||
|
final double oldDragExtent = _dragExtent;
|
||||||
switch (config.direction) {
|
switch (config.direction) {
|
||||||
case DismissDirection.horizontal:
|
case DismissDirection.horizontal:
|
||||||
case DismissDirection.vertical:
|
case DismissDirection.vertical:
|
||||||
@ -236,14 +237,14 @@ class _DismissableState extends State<Dismissable> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragEnd(Velocity velocity) {
|
void _handleDragEnd(DragEndDetails details) {
|
||||||
if (!_isActive || _moveController.isAnimating)
|
if (!_isActive || _moveController.isAnimating)
|
||||||
return;
|
return;
|
||||||
_dragUnderway = false;
|
_dragUnderway = false;
|
||||||
if (_moveController.isCompleted) {
|
if (_moveController.isCompleted) {
|
||||||
_startResizeAnimation();
|
_startResizeAnimation();
|
||||||
} else if (_isFlingGesture(velocity)) {
|
} else if (_isFlingGesture(details.velocity)) {
|
||||||
double flingVelocity = _directionIsXAxis ? velocity.pixelsPerSecond.dx : velocity.pixelsPerSecond.dy;
|
double flingVelocity = _directionIsXAxis ? details.velocity.pixelsPerSecond.dx : details.velocity.pixelsPerSecond.dy;
|
||||||
_dragExtent = flingVelocity.sign;
|
_dragExtent = flingVelocity.sign;
|
||||||
_moveController.fling(velocity: flingVelocity.abs() * _kFlingVelocityScale);
|
_moveController.fling(velocity: flingVelocity.abs() * _kFlingVelocityScale);
|
||||||
} else if (_moveController.value > _kDismissThreshold) {
|
} else if (_moveController.value > _kDismissThreshold) {
|
||||||
|
@ -9,6 +9,10 @@ import 'basic.dart';
|
|||||||
import 'framework.dart';
|
import 'framework.dart';
|
||||||
|
|
||||||
export 'package:flutter/gestures.dart' show
|
export 'package:flutter/gestures.dart' show
|
||||||
|
DragDownDetails,
|
||||||
|
DragStartDetails,
|
||||||
|
DragUpdateDetails,
|
||||||
|
DragEndDetails,
|
||||||
GestureTapDownCallback,
|
GestureTapDownCallback,
|
||||||
GestureTapUpCallback,
|
GestureTapUpCallback,
|
||||||
GestureTapCallback,
|
GestureTapCallback,
|
||||||
@ -19,11 +23,6 @@ export 'package:flutter/gestures.dart' show
|
|||||||
GestureDragUpdateCallback,
|
GestureDragUpdateCallback,
|
||||||
GestureDragEndCallback,
|
GestureDragEndCallback,
|
||||||
GestureDragCancelCallback,
|
GestureDragCancelCallback,
|
||||||
GesturePanDownCallback,
|
|
||||||
GesturePanStartCallback,
|
|
||||||
GesturePanUpdateCallback,
|
|
||||||
GesturePanEndCallback,
|
|
||||||
GesturePanCancelCallback,
|
|
||||||
GestureScaleStartCallback,
|
GestureScaleStartCallback,
|
||||||
GestureScaleUpdateCallback,
|
GestureScaleUpdateCallback,
|
||||||
GestureScaleEndCallback,
|
GestureScaleEndCallback,
|
||||||
@ -162,21 +161,21 @@ class GestureDetector extends StatelessWidget {
|
|||||||
final GestureDragCancelCallback onHorizontalDragCancel;
|
final GestureDragCancelCallback onHorizontalDragCancel;
|
||||||
|
|
||||||
/// A pointer has contacted the screen and might begin to move.
|
/// A pointer has contacted the screen and might begin to move.
|
||||||
final GesturePanDownCallback onPanDown;
|
final GestureDragDownCallback onPanDown;
|
||||||
|
|
||||||
/// A pointer has contacted the screen and has begun to move.
|
/// A pointer has contacted the screen and has begun to move.
|
||||||
final GesturePanStartCallback onPanStart;
|
final GestureDragStartCallback onPanStart;
|
||||||
|
|
||||||
/// A pointer that is in contact with the screen and moving has moved again.
|
/// A pointer that is in contact with the screen and moving has moved again.
|
||||||
final GesturePanUpdateCallback onPanUpdate;
|
final GestureDragUpdateCallback onPanUpdate;
|
||||||
|
|
||||||
/// A pointer that was previously in contact with the screen and moving
|
/// A pointer that was previously in contact with the screen and moving
|
||||||
/// is no longer in contact with the screen and was moving at a specific
|
/// is no longer in contact with the screen and was moving at a specific
|
||||||
/// velocity when it stopped contacting the screen.
|
/// velocity when it stopped contacting the screen.
|
||||||
final GesturePanEndCallback onPanEnd;
|
final GestureDragEndCallback onPanEnd;
|
||||||
|
|
||||||
/// The pointer that previously triggered [onPanDown] did not complete.
|
/// The pointer that previously triggered [onPanDown] did not complete.
|
||||||
final GesturePanCancelCallback onPanCancel;
|
final GestureDragCancelCallback onPanCancel;
|
||||||
|
|
||||||
/// The pointers in contact with the screen have established a focal point and
|
/// The pointers in contact with the screen have established a focal point and
|
||||||
/// initial scale of 1.0.
|
/// initial scale of 1.0.
|
||||||
@ -474,16 +473,16 @@ class _GestureSemantics extends SingleChildRenderObjectWidget {
|
|||||||
recognizer.onLongPress();
|
recognizer.onLongPress();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleHorizontalDragUpdate(double delta) {
|
void _handleHorizontalDragUpdate(DragUpdateDetails updateDetails) {
|
||||||
{
|
{
|
||||||
HorizontalDragGestureRecognizer recognizer = owner._recognizers[HorizontalDragGestureRecognizer];
|
HorizontalDragGestureRecognizer recognizer = owner._recognizers[HorizontalDragGestureRecognizer];
|
||||||
if (recognizer != null) {
|
if (recognizer != null) {
|
||||||
if (recognizer.onStart != null)
|
if (recognizer.onStart != null)
|
||||||
recognizer.onStart(Point.origin);
|
recognizer.onStart(new DragStartDetails());
|
||||||
if (recognizer.onUpdate != null)
|
if (recognizer.onUpdate != null)
|
||||||
recognizer.onUpdate(delta);
|
recognizer.onUpdate(updateDetails);
|
||||||
if (recognizer.onEnd != null)
|
if (recognizer.onEnd != null)
|
||||||
recognizer.onEnd(Velocity.zero);
|
recognizer.onEnd(new DragEndDetails());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,27 +490,27 @@ class _GestureSemantics extends SingleChildRenderObjectWidget {
|
|||||||
PanGestureRecognizer recognizer = owner._recognizers[PanGestureRecognizer];
|
PanGestureRecognizer recognizer = owner._recognizers[PanGestureRecognizer];
|
||||||
if (recognizer != null) {
|
if (recognizer != null) {
|
||||||
if (recognizer.onStart != null)
|
if (recognizer.onStart != null)
|
||||||
recognizer.onStart(Point.origin);
|
recognizer.onStart(new DragStartDetails());
|
||||||
if (recognizer.onUpdate != null)
|
if (recognizer.onUpdate != null)
|
||||||
recognizer.onUpdate(new Offset(delta, 0.0));
|
recognizer.onUpdate(updateDetails);
|
||||||
if (recognizer.onEnd != null)
|
if (recognizer.onEnd != null)
|
||||||
recognizer.onEnd(Velocity.zero);
|
recognizer.onEnd(new DragEndDetails());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleVerticalDragUpdate(double delta) {
|
void _handleVerticalDragUpdate(DragUpdateDetails updateDetails) {
|
||||||
{
|
{
|
||||||
VerticalDragGestureRecognizer recognizer = owner._recognizers[VerticalDragGestureRecognizer];
|
VerticalDragGestureRecognizer recognizer = owner._recognizers[VerticalDragGestureRecognizer];
|
||||||
if (recognizer != null) {
|
if (recognizer != null) {
|
||||||
if (recognizer.onStart != null)
|
if (recognizer.onStart != null)
|
||||||
recognizer.onStart(Point.origin);
|
recognizer.onStart(new DragStartDetails());
|
||||||
if (recognizer.onUpdate != null)
|
if (recognizer.onUpdate != null)
|
||||||
recognizer.onUpdate(delta);
|
recognizer.onUpdate(updateDetails);
|
||||||
if (recognizer.onEnd != null)
|
if (recognizer.onEnd != null)
|
||||||
recognizer.onEnd(Velocity.zero);
|
recognizer.onEnd(new DragEndDetails());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -519,11 +518,11 @@ class _GestureSemantics extends SingleChildRenderObjectWidget {
|
|||||||
PanGestureRecognizer recognizer = owner._recognizers[PanGestureRecognizer];
|
PanGestureRecognizer recognizer = owner._recognizers[PanGestureRecognizer];
|
||||||
if (recognizer != null) {
|
if (recognizer != null) {
|
||||||
if (recognizer.onStart != null)
|
if (recognizer.onStart != null)
|
||||||
recognizer.onStart(Point.origin);
|
recognizer.onStart(new DragStartDetails());
|
||||||
if (recognizer.onUpdate != null)
|
if (recognizer.onUpdate != null)
|
||||||
recognizer.onUpdate(new Offset(0.0, delta));
|
recognizer.onUpdate(updateDetails);
|
||||||
if (recognizer.onEnd != null)
|
if (recognizer.onEnd != null)
|
||||||
recognizer.onEnd(Velocity.zero);
|
recognizer.onEnd(new DragEndDetails());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,7 +522,7 @@ class ScrollableState<T extends Scrollable> extends State<T> {
|
|||||||
_simulation = null;
|
_simulation = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragStart(_) {
|
void _handleDragStart(DragStartDetails details) {
|
||||||
_startScroll();
|
_startScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,12 +542,12 @@ class ScrollableState<T extends Scrollable> extends State<T> {
|
|||||||
new ScrollNotification(this, ScrollNotificationKind.started).dispatch(context);
|
new ScrollNotification(this, ScrollNotificationKind.started).dispatch(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragUpdate(double delta) {
|
void _handleDragUpdate(DragUpdateDetails details) {
|
||||||
scrollBy(pixelOffsetToScrollOffset(delta));
|
scrollBy(pixelOffsetToScrollOffset(details.primaryDelta));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> _handleDragEnd(Velocity velocity) {
|
Future<Null> _handleDragEnd(DragEndDetails details) {
|
||||||
double scrollVelocity = pixelDeltaToScrollOffset(velocity.pixelsPerSecond) / Duration.MILLISECONDS_PER_SECOND;
|
double scrollVelocity = pixelDeltaToScrollOffset(details.velocity.pixelsPerSecond) / Duration.MILLISECONDS_PER_SECOND;
|
||||||
return fling(scrollVelocity).then(_endScroll);
|
return fling(scrollVelocity).then(_endScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +66,9 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> {
|
|||||||
_lastPointerDownLocation = null;
|
_lastPointerDownLocation = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void _handlePanEnd(Velocity velocity) {
|
void _handlePanEnd(DragEndDetails details) {
|
||||||
assert(_lastPointerDownLocation != null);
|
assert(_lastPointerDownLocation != null);
|
||||||
_SemanticsDebuggerListener.instance.handlePanEnd(_lastPointerDownLocation, velocity);
|
_SemanticsDebuggerListener.instance.handlePanEnd(_lastPointerDownLocation, details.velocity);
|
||||||
setState(() {
|
setState(() {
|
||||||
_lastPointerDownLocation = null;
|
_lastPointerDownLocation = null;
|
||||||
});
|
});
|
||||||
|
@ -205,12 +205,12 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
|
|||||||
|
|
||||||
class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay> {
|
class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay> {
|
||||||
Point _dragPosition;
|
Point _dragPosition;
|
||||||
void _handleDragStart(Point position) {
|
void _handleDragStart(DragStartDetails details) {
|
||||||
_dragPosition = position;
|
_dragPosition = details.globalPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDragUpdate(double delta) {
|
void _handleDragUpdate(DragUpdateDetails details) {
|
||||||
_dragPosition += new Offset(delta, 0.0);
|
_dragPosition += details.delta;
|
||||||
TextPosition position = config.renderObject.getPositionForPoint(_dragPosition);
|
TextPosition position = config.renderObject.getPositionForPoint(_dragPosition);
|
||||||
|
|
||||||
if (config.selection.isCollapsed) {
|
if (config.selection.isCollapsed) {
|
||||||
|
@ -104,7 +104,7 @@ void main() {
|
|||||||
bool isDangerousStack = false;
|
bool isDangerousStack = false;
|
||||||
|
|
||||||
bool dragStartRecognized = false;
|
bool dragStartRecognized = false;
|
||||||
drag.onStart = (Point globalPosition) {
|
drag.onStart = (DragStartDetails details) {
|
||||||
expect(isDangerousStack, isFalse);
|
expect(isDangerousStack, isFalse);
|
||||||
dragStartRecognized = true;
|
dragStartRecognized = true;
|
||||||
};
|
};
|
||||||
|
@ -20,12 +20,12 @@ void main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Offset updatedScrollDelta;
|
Offset updatedScrollDelta;
|
||||||
pan.onUpdate = (Offset offset) {
|
pan.onUpdate = (DragUpdateDetails details) {
|
||||||
updatedScrollDelta = offset;
|
updatedScrollDelta = details.delta;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool didEndPan = false;
|
bool didEndPan = false;
|
||||||
pan.onEnd = (Velocity velocity) {
|
pan.onEnd = (DragEndDetails details) {
|
||||||
didEndPan = true;
|
didEndPan = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -85,12 +85,12 @@ void main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
double updatedDelta;
|
double updatedDelta;
|
||||||
drag.onUpdate = (double delta) {
|
drag.onUpdate = (DragUpdateDetails details) {
|
||||||
updatedDelta = delta;
|
updatedDelta = details.primaryDelta;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool didEndDrag = false;
|
bool didEndDrag = false;
|
||||||
drag.onEnd = (Velocity velocity) {
|
drag.onEnd = (DragEndDetails details) {
|
||||||
didEndDrag = true;
|
didEndDrag = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@ void main() {
|
|||||||
bool didEndDrag = false;
|
bool didEndDrag = false;
|
||||||
|
|
||||||
Widget widget = new GestureDetector(
|
Widget widget = new GestureDetector(
|
||||||
onVerticalDragStart: (_) {
|
onVerticalDragStart: (DragStartDetails details) {
|
||||||
didStartDrag = true;
|
didStartDrag = true;
|
||||||
},
|
},
|
||||||
onVerticalDragUpdate: (double scrollDelta) {
|
onVerticalDragUpdate: (DragUpdateDetails details) {
|
||||||
updatedDragDelta = scrollDelta;
|
updatedDragDelta = details.primaryDelta;
|
||||||
},
|
},
|
||||||
onVerticalDragEnd: (Velocity velocity) {
|
onVerticalDragEnd: (DragEndDetails details) {
|
||||||
didEndDrag = true;
|
didEndDrag = true;
|
||||||
},
|
},
|
||||||
child: new Container(
|
child: new Container(
|
||||||
@ -64,10 +64,10 @@ void main() {
|
|||||||
Point upLocation = new Point(10.0, 20.0);
|
Point upLocation = new Point(10.0, 20.0);
|
||||||
|
|
||||||
Widget widget = new GestureDetector(
|
Widget widget = new GestureDetector(
|
||||||
onVerticalDragUpdate: (double delta) { dragDistance += delta; },
|
onVerticalDragUpdate: (DragUpdateDetails details) { dragDistance += details.primaryDelta; },
|
||||||
onVerticalDragEnd: (Velocity velocity) { gestureCount += 1; },
|
onVerticalDragEnd: (DragEndDetails details) { gestureCount += 1; },
|
||||||
onHorizontalDragUpdate: (_) { fail("gesture should not match"); },
|
onHorizontalDragUpdate: (DragUpdateDetails details) { fail("gesture should not match"); },
|
||||||
onHorizontalDragEnd: (Velocity velocity) { fail("gesture should not match"); },
|
onHorizontalDragEnd: (DragEndDetails details) { fail("gesture should not match"); },
|
||||||
child: new Container(
|
child: new Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
backgroundColor: const Color(0xFF00FF00)
|
backgroundColor: const Color(0xFF00FF00)
|
||||||
@ -97,13 +97,13 @@ void main() {
|
|||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new GestureDetector(
|
new GestureDetector(
|
||||||
onPanStart: (_) {
|
onPanStart: (DragStartDetails details) {
|
||||||
didStartPan = true;
|
didStartPan = true;
|
||||||
},
|
},
|
||||||
onPanUpdate: (Offset delta) {
|
onPanUpdate: (DragUpdateDetails details) {
|
||||||
panDelta = delta;
|
panDelta = details.delta;
|
||||||
},
|
},
|
||||||
onPanEnd: (_) {
|
onPanEnd: (DragEndDetails details) {
|
||||||
didEndPan = true;
|
didEndPan = true;
|
||||||
},
|
},
|
||||||
child: new Container(
|
child: new Container(
|
||||||
|
Loading…
Reference in New Issue
Block a user