PinchDepthRecognizer class
Converts a two-finger pinch gesture into a Z-depth (zoom) delta.
Pinching in (fingers approaching) decreases depth — moves the object away. Pinching out (fingers spreading) increases depth — brings the object closer.
Usage
final pinch = PinchDepthRecognizer(
onDepthChanged: (delta) {
setState(() => _z += delta);
},
);
GestureDetector(
onScaleStart: pinch.onScaleStart,
onScaleUpdate: pinch.onScaleUpdate,
onScaleEnd: pinch.onScaleEnd,
child: MyWidget(),
)
Constructors
- PinchDepthRecognizer({required void onDepthChanged(double depthDelta), double depthPerUnit = 200, double threshold = 0.005})
Properties
- depthPerUnit → double
-
Multiplier: how many logical pixels to move per unit of scale change.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- onDepthChanged → void Function(double depthDelta)
-
Called with the Z-depth delta each scale update.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- threshold → double
-
Minimum scale ratio — rejects micro-changes to avoid jitter.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onScaleEnd(
ScaleEndDetails _) → void -
onScaleStart(
ScaleStartDetails _) → void -
onScaleUpdate(
ScaleUpdateDetails d) → void -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited