@@ -371,11 +371,14 @@ class TransformableBox extends StatefulWidget {
371371
372372enum _PrimaryGestureOperation {
373373 resize,
374- drag;
374+ drag,
375+ rotate;
375376
376377 bool get isDragging => this == _PrimaryGestureOperation .drag;
377378
378379 bool get isResizing => this == _PrimaryGestureOperation .resize;
380+
381+ bool get isRotating => this == _PrimaryGestureOperation .rotate;
379382}
380383
381384class _TransformableBoxState extends State <TransformableBox > {
@@ -389,7 +392,9 @@ class _TransformableBoxState extends State<TransformableBox> {
389392
390393 bool get isResizing => primaryGestureOperation? .isResizing == true ;
391394
392- bool get isGestureActive => isDragging || isResizing;
395+ bool get isRotating => primaryGestureOperation? .isRotating == true ;
396+
397+ bool get isGestureActive => isDragging || isResizing || isRotating;
393398
394399 bool mismatchedHandle (HandlePosition handle) =>
395400 lastHandle != null && lastHandle != handle;
@@ -595,28 +600,35 @@ class _TransformableBoxState extends State<TransformableBox> {
595600 };
596601
597602 void onHandleRotateStart (DragStartDetails event, HandlePosition handle) {
603+ if (isGestureActive) return ;
604+
605+ primaryGestureOperation = _PrimaryGestureOperation .rotate;
606+ lastHandle = handle;
607+
598608 final offset =
599609 widget.handleAlignment.offset (widget.rotationHandleGestureSize);
600610 initialPos = rectQuadrantOffset (handle.quadrant) +
601611 event.localPosition -
602612 Offset (offset, offset);
603613 localPos = initialPos;
604614 setState (() {});
615+
605616 // Two fingers were used to start the drag. This produces issues with
606617 // the box drag event. Therefore, we ignore it.
607- if (event.kind == PointerDeviceKind .trackpad) {
608- isLegalGesture = false ;
609- return ;
610- } else {
611- isLegalGesture = true ;
612- }
618+ // if (event.kind == PointerDeviceKind.trackpad) {
619+ // isLegalGesture = false;
620+ // return;
621+ // } else {
622+ // isLegalGesture = true;
623+ // }
613624
614625 controller.onRotateStart (initialPos);
615626 widget.onRotationStart? .call (handle, event);
616627 }
617628
618629 void onHandleRotateUpdate (DragUpdateDetails event, HandlePosition handle) {
619- if (! isLegalGesture) return ;
630+ if (! isGestureActive) return ;
631+
620632 final offset =
621633 widget.handleAlignment.offset (widget.rotationHandleGestureSize);
622634 localPos = rectQuadrantOffset (handle.quadrant) +
@@ -652,7 +664,10 @@ class _TransformableBoxState extends State<TransformableBox> {
652664 }
653665
654666 void onHandleRotateEnd (DragEndDetails event, HandlePosition handle) {
655- if (! isLegalGesture) return ;
667+ if (! isGestureActive) return ;
668+
669+ primaryGestureOperation = null ;
670+ lastHandle = null ;
656671
657672 controller.onRotateEnd ();
658673 widget.onRotationEnd? .call (handle, event);
@@ -666,7 +681,10 @@ class _TransformableBoxState extends State<TransformableBox> {
666681 }
667682
668683 void onHandleRotateCancel (HandlePosition handle) {
669- if (! isLegalGesture) return ;
684+ if (! isGestureActive) return ;
685+
686+ primaryGestureOperation = null ;
687+ lastHandle = null ;
670688
671689 controller.onRotateEnd ();
672690 widget.onRotationCancel? .call (handle);
@@ -825,7 +843,8 @@ class _TransformableBoxState extends State<TransformableBox> {
825843 resizeHandleGestureSize: widget.resizeHandleGestureSize,
826844 rotationHandleGestureSize:
827845 widget.rotationHandleGestureSize,
828- supportedDevices: widget.supportedResizeDevices,enabled: widget.enabledHandles.contains (handle),
846+ supportedDevices: widget.supportedResizeDevices,
847+ enabled: widget.enabledHandles.contains (handle),
829848 visible: widget.visibleHandles.contains (handle),
830849 rotatable: widget.rotatable,
831850 // Resize
@@ -855,7 +874,7 @@ class _TransformableBoxState extends State<TransformableBox> {
855874 rotationHandleGestureSize:
856875 widget.rotationHandleGestureSize,
857876 rotatable: widget.rotatable,
858- supportedDevices: widget.supportedResizeDevices,
877+ supportedDevices: widget.supportedResizeDevices,
859878 enabled: widget.enabledHandles.contains (handle),
860879 visible: widget.visibleHandles.contains (handle),
861880 onPanStart: (event) => onHandlePanStart (event, handle),
0 commit comments