@@ -393,6 +393,14 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
393
393
/// {@endtemplate}
394
394
Offset trackpadScrollToScaleFactor;
395
395
396
+ /// The number of pointers being tracked by the gesture recognizer.
397
+ ///
398
+ /// Typically this is the number of fingers being used to pan the widget using the gesture
399
+ /// recognizer.
400
+ int get pointerCount {
401
+ return _pointerPanZooms.length + _pointerQueue.length;
402
+ }
403
+
396
404
late Offset _initialFocalPoint;
397
405
Offset ? _currentFocalPoint;
398
406
late double _initialSpan;
@@ -443,10 +451,6 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
443
451
return scale;
444
452
}
445
453
446
- int get _pointerCount {
447
- return _pointerPanZooms.length + _pointerQueue.length;
448
- }
449
-
450
454
double _computeRotationFactor () {
451
455
double factor = 0.0 ;
452
456
if (_initialLine != null && _currentLine != null ) {
@@ -566,7 +570,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
566
570
for (final _PointerPanZoomData p in _pointerPanZooms.values) {
567
571
focalPoint += p.focalPoint;
568
572
}
569
- _currentFocalPoint = _pointerCount > 0 ? focalPoint / _pointerCount .toDouble () : Offset .zero;
573
+ _currentFocalPoint = pointerCount > 0 ? focalPoint / pointerCount .toDouble () : Offset .zero;
570
574
571
575
if (previousFocalPoint == null ) {
572
576
_localFocalPoint = PointerEvent .transformPosition (
@@ -662,9 +666,9 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
662
666
if (pixelsPerSecond.distanceSquared > kMaxFlingVelocity * kMaxFlingVelocity) {
663
667
velocity = Velocity (pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity);
664
668
}
665
- invokeCallback <void >('onEnd' , () => onEnd !(ScaleEndDetails (velocity: velocity, scaleVelocity: _scaleVelocityTracker? .getVelocity ().pixelsPerSecond.dx ?? - 1 , pointerCount: _pointerCount )));
669
+ invokeCallback <void >('onEnd' , () => onEnd !(ScaleEndDetails (velocity: velocity, scaleVelocity: _scaleVelocityTracker? .getVelocity ().pixelsPerSecond.dx ?? - 1 , pointerCount: pointerCount )));
666
670
} else {
667
- invokeCallback <void >('onEnd' , () => onEnd !(ScaleEndDetails (scaleVelocity: _scaleVelocityTracker? .getVelocity ().pixelsPerSecond.dx ?? - 1 , pointerCount: _pointerCount )));
671
+ invokeCallback <void >('onEnd' , () => onEnd !(ScaleEndDetails (scaleVelocity: _scaleVelocityTracker? .getVelocity ().pixelsPerSecond.dx ?? - 1 , pointerCount: pointerCount )));
668
672
}
669
673
}
670
674
_state = _ScaleState .accepted;
@@ -706,7 +710,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
706
710
focalPoint: _currentFocalPoint! ,
707
711
localFocalPoint: _localFocalPoint,
708
712
rotation: _computeRotationFactor (),
709
- pointerCount: _pointerCount ,
713
+ pointerCount: pointerCount ,
710
714
focalPointDelta: _delta,
711
715
));
712
716
});
@@ -721,7 +725,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
721
725
onStart !(ScaleStartDetails (
722
726
focalPoint: _currentFocalPoint! ,
723
727
localFocalPoint: _localFocalPoint,
724
- pointerCount: _pointerCount ,
728
+ pointerCount: pointerCount ,
725
729
));
726
730
});
727
731
}
0 commit comments