From 5443ce3fda8a4ce974bb7d8a86b277be543957b3 Mon Sep 17 00:00:00 2001 From: PRATYUSH TIWARI <42827589+1-2-ka-4-4-2-ka-1@users.noreply.github.com> Date: Sun, 17 May 2020 09:30:15 -0700 Subject: [PATCH] Added callback method 'onMatrixUpdateEnd:' Added callback method 'onMatrixUpdateEnd' to notify update matrix update ended. fixes # 11 --- lib/matrix_gesture_detector.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/matrix_gesture_detector.dart b/lib/matrix_gesture_detector.dart index eb5e038..97c41c4 100644 --- a/lib/matrix_gesture_detector.dart +++ b/lib/matrix_gesture_detector.dart @@ -21,6 +21,10 @@ class MatrixGestureDetector extends StatefulWidget { /// [Matrix4] change notification callback /// final MatrixGestureDetectorCallback onMatrixUpdate; + /// + /// Callback to notify the update ended. + /// + final Function onMatrixUpdateEnd; /// The [child] contained by this detector. /// @@ -65,6 +69,7 @@ class MatrixGestureDetector extends StatefulWidget { this.shouldRotate = true, this.clipChild = true, this.focalPointAlignment, + this.onMatrixUpdateEnd }) : assert(onMatrixUpdate != null), assert(child != null), super(key: key); @@ -111,10 +116,11 @@ class _MatrixGestureDetectorState extends State { @override Widget build(BuildContext context) { Widget child = - widget.clipChild ? ClipRect(child: widget.child) : widget.child; + widget.clipChild ? ClipRect(child: widget.child) : widget.child; return GestureDetector( onScaleStart: onScaleStart, onScaleUpdate: onScaleUpdate, + onScaleEnd: onScaleEnd, child: child, ); } @@ -135,6 +141,11 @@ class _MatrixGestureDetectorState extends State { scaleUpdater.value = 1.0; } + void onScaleEnd(ScaleEndDetails details){ + if(widget.onMatrixUpdateEnd!= null) + widget.onMatrixUpdateEnd(details); + } + void onScaleUpdate(ScaleUpdateDetails details) { translationDeltaMatrix = Matrix4.identity(); scaleDeltaMatrix = Matrix4.identity();