@@ -371,11 +371,14 @@ class TransformableBox extends StatefulWidget {
371
371
372
372
enum _PrimaryGestureOperation {
373
373
resize,
374
- drag;
374
+ drag,
375
+ rotate;
375
376
376
377
bool get isDragging => this == _PrimaryGestureOperation .drag;
377
378
378
379
bool get isResizing => this == _PrimaryGestureOperation .resize;
380
+
381
+ bool get isRotating => this == _PrimaryGestureOperation .rotate;
379
382
}
380
383
381
384
class _TransformableBoxState extends State <TransformableBox > {
@@ -389,7 +392,9 @@ class _TransformableBoxState extends State<TransformableBox> {
389
392
390
393
bool get isResizing => primaryGestureOperation? .isResizing == true ;
391
394
392
- bool get isGestureActive => isDragging || isResizing;
395
+ bool get isRotating => primaryGestureOperation? .isRotating == true ;
396
+
397
+ bool get isGestureActive => isDragging || isResizing || isRotating;
393
398
394
399
bool mismatchedHandle (HandlePosition handle) =>
395
400
lastHandle != null && lastHandle != handle;
@@ -595,28 +600,35 @@ class _TransformableBoxState extends State<TransformableBox> {
595
600
};
596
601
597
602
void onHandleRotateStart (DragStartDetails event, HandlePosition handle) {
603
+ if (isGestureActive) return ;
604
+
605
+ primaryGestureOperation = _PrimaryGestureOperation .rotate;
606
+ lastHandle = handle;
607
+
598
608
final offset =
599
609
widget.handleAlignment.offset (widget.rotationHandleGestureSize);
600
610
initialPos = rectQuadrantOffset (handle.quadrant) +
601
611
event.localPosition -
602
612
Offset (offset, offset);
603
613
localPos = initialPos;
604
614
setState (() {});
615
+
605
616
// Two fingers were used to start the drag. This produces issues with
606
617
// 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
+ // }
613
624
614
625
controller.onRotateStart (initialPos);
615
626
widget.onRotationStart? .call (handle, event);
616
627
}
617
628
618
629
void onHandleRotateUpdate (DragUpdateDetails event, HandlePosition handle) {
619
- if (! isLegalGesture) return ;
630
+ if (! isGestureActive) return ;
631
+
620
632
final offset =
621
633
widget.handleAlignment.offset (widget.rotationHandleGestureSize);
622
634
localPos = rectQuadrantOffset (handle.quadrant) +
@@ -652,7 +664,10 @@ class _TransformableBoxState extends State<TransformableBox> {
652
664
}
653
665
654
666
void onHandleRotateEnd (DragEndDetails event, HandlePosition handle) {
655
- if (! isLegalGesture) return ;
667
+ if (! isGestureActive) return ;
668
+
669
+ primaryGestureOperation = null ;
670
+ lastHandle = null ;
656
671
657
672
controller.onRotateEnd ();
658
673
widget.onRotationEnd? .call (handle, event);
@@ -666,7 +681,10 @@ class _TransformableBoxState extends State<TransformableBox> {
666
681
}
667
682
668
683
void onHandleRotateCancel (HandlePosition handle) {
669
- if (! isLegalGesture) return ;
684
+ if (! isGestureActive) return ;
685
+
686
+ primaryGestureOperation = null ;
687
+ lastHandle = null ;
670
688
671
689
controller.onRotateEnd ();
672
690
widget.onRotationCancel? .call (handle);
@@ -825,7 +843,8 @@ class _TransformableBoxState extends State<TransformableBox> {
825
843
resizeHandleGestureSize: widget.resizeHandleGestureSize,
826
844
rotationHandleGestureSize:
827
845
widget.rotationHandleGestureSize,
828
- supportedDevices: widget.supportedResizeDevices,enabled: widget.enabledHandles.contains (handle),
846
+ supportedDevices: widget.supportedResizeDevices,
847
+ enabled: widget.enabledHandles.contains (handle),
829
848
visible: widget.visibleHandles.contains (handle),
830
849
rotatable: widget.rotatable,
831
850
// Resize
@@ -855,7 +874,7 @@ class _TransformableBoxState extends State<TransformableBox> {
855
874
rotationHandleGestureSize:
856
875
widget.rotationHandleGestureSize,
857
876
rotatable: widget.rotatable,
858
- supportedDevices: widget.supportedResizeDevices,
877
+ supportedDevices: widget.supportedResizeDevices,
859
878
enabled: widget.enabledHandles.contains (handle),
860
879
visible: widget.visibleHandles.contains (handle),
861
880
onPanStart: (event) => onHandlePanStart (event, handle),
0 commit comments