Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/matrix_gesture_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -111,10 +116,11 @@ class _MatrixGestureDetectorState extends State<MatrixGestureDetector> {
@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,
);
}
Expand All @@ -135,6 +141,11 @@ class _MatrixGestureDetectorState extends State<MatrixGestureDetector> {
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();
Expand Down