@@ -36,7 +36,7 @@ class ScaleStartDetails {
36
36
/// Creates details for [GestureScaleStartCallback] .
37
37
///
38
38
/// The [focalPoint] argument must not be null.
39
- ScaleStartDetails ({ this .focalPoint = Offset .zero, Offset ? localFocalPoint, })
39
+ ScaleStartDetails ({ this .focalPoint = Offset .zero, Offset ? localFocalPoint, this .pointerCount = 0 })
40
40
: assert (focalPoint != null ), localFocalPoint = localFocalPoint ?? focalPoint;
41
41
42
42
/// The initial focal point of the pointers in contact with the screen.
@@ -60,8 +60,14 @@ class ScaleStartDetails {
60
60
/// coordinates.
61
61
final Offset localFocalPoint;
62
62
63
+ /// The number of pointers being tracked by the gesture recognizer.
64
+ ///
65
+ /// Typically this is the number of fingers being used to pan the widget using the gesture
66
+ /// recognizer.
67
+ final int pointerCount;
68
+
63
69
@override
64
- String toString () => 'ScaleStartDetails(focalPoint: $focalPoint , localFocalPoint: $localFocalPoint )' ;
70
+ String toString () => 'ScaleStartDetails(focalPoint: $focalPoint , localFocalPoint: $localFocalPoint , pointersCount: $ pointerCount )' ;
65
71
}
66
72
67
73
/// Details for [GestureScaleUpdateCallback] .
@@ -78,6 +84,7 @@ class ScaleUpdateDetails {
78
84
this .horizontalScale = 1.0 ,
79
85
this .verticalScale = 1.0 ,
80
86
this .rotation = 0.0 ,
87
+ this .pointerCount = 0 ,
81
88
}) : assert (focalPoint != null ),
82
89
assert (scale != null && scale >= 0.0 ),
83
90
assert (horizontalScale != null && horizontalScale >= 0.0 ),
@@ -145,23 +152,42 @@ class ScaleUpdateDetails {
145
152
/// Expressed in radians.
146
153
final double rotation;
147
154
155
+ /// The number of pointers being tracked by the gesture recognizer.
156
+ ///
157
+ /// Typically this is the number of fingers being used to pan the widget using the gesture
158
+ /// recognizer.
159
+ final int pointerCount;
160
+
148
161
@override
149
- String toString () => 'ScaleUpdateDetails(focalPoint: $focalPoint , localFocalPoint: $localFocalPoint , scale: $scale , horizontalScale: $horizontalScale , verticalScale: $verticalScale , rotation: $rotation )' ;
162
+ String toString () => 'ScaleUpdateDetails('
163
+ 'focalPoint: $focalPoint ,'
164
+ ' localFocalPoint: $localFocalPoint ,'
165
+ ' scale: $scale ,'
166
+ ' horizontalScale: $horizontalScale ,'
167
+ ' verticalScale: $verticalScale ,'
168
+ ' rotation: $rotation ,'
169
+ ' pointerCount: $pointerCount )' ;
150
170
}
151
171
152
172
/// Details for [GestureScaleEndCallback] .
153
173
class ScaleEndDetails {
154
174
/// Creates details for [GestureScaleEndCallback] .
155
175
///
156
176
/// The [velocity] argument must not be null.
157
- ScaleEndDetails ({ this .velocity = Velocity .zero })
177
+ ScaleEndDetails ({ this .velocity = Velocity .zero, this .pointerCount = 0 })
158
178
: assert (velocity != null );
159
179
160
180
/// The velocity of the last pointer to be lifted off of the screen.
161
181
final Velocity velocity;
162
182
183
+ /// The number of pointers being tracked by the gesture recognizer.
184
+ ///
185
+ /// Typically this is the number of fingers being used to pan the widget using the gesture
186
+ /// recognizer.
187
+ final int pointerCount;
188
+
163
189
@override
164
- String toString () => 'ScaleEndDetails(velocity: $velocity )' ;
190
+ String toString () => 'ScaleEndDetails(velocity: $velocity , pointerCount: $ pointerCount )' ;
165
191
}
166
192
167
193
/// Signature for when the pointers in contact with the screen have established
@@ -434,9 +460,9 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
434
460
final Offset pixelsPerSecond = velocity.pixelsPerSecond;
435
461
if (pixelsPerSecond.distanceSquared > kMaxFlingVelocity * kMaxFlingVelocity)
436
462
velocity = Velocity (pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity);
437
- invokeCallback <void >('onEnd' , () => onEnd !(ScaleEndDetails (velocity: velocity)));
463
+ invokeCallback <void >('onEnd' , () => onEnd !(ScaleEndDetails (velocity: velocity, pointerCount : _pointerQueue.length )));
438
464
} else {
439
- invokeCallback <void >('onEnd' , () => onEnd !(ScaleEndDetails (velocity: Velocity .zero)));
465
+ invokeCallback <void >('onEnd' , () => onEnd !(ScaleEndDetails (velocity: Velocity .zero, pointerCount : _pointerQueue.length )));
440
466
}
441
467
}
442
468
_state = _ScaleState .accepted;
@@ -472,6 +498,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
472
498
focalPoint: _currentFocalPoint,
473
499
localFocalPoint: PointerEvent .transformPosition (_lastTransform, _currentFocalPoint),
474
500
rotation: _computeRotationFactor (),
501
+ pointerCount: _pointerQueue.length,
475
502
));
476
503
});
477
504
}
@@ -483,6 +510,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
483
510
onStart !(ScaleStartDetails (
484
511
focalPoint: _currentFocalPoint,
485
512
localFocalPoint: PointerEvent .transformPosition (_lastTransform, _currentFocalPoint),
513
+ pointerCount: _pointerQueue.length,
486
514
));
487
515
});
488
516
}
0 commit comments