@@ -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;
@@ -602,28 +607,35 @@ class _TransformableBoxState extends State<TransformableBox> {
602
607
};
603
608
604
609
void onHandleRotateStart (DragStartDetails event, HandlePosition handle) {
610
+ if (isGestureActive) return ;
611
+
612
+ primaryGestureOperation = _PrimaryGestureOperation .rotate;
613
+ lastHandle = handle;
614
+
605
615
final offset =
606
616
widget.handleAlignment.offset (widget.rotationHandleGestureSize);
607
617
initialPos = rectQuadrantOffset (handle.quadrant) +
608
618
event.localPosition -
609
619
Offset (offset, offset);
610
620
localPos = initialPos;
611
621
setState (() {});
622
+
612
623
// Two fingers were used to start the drag. This produces issues with
613
624
// the box drag event. Therefore, we ignore it.
614
- if (event.kind == PointerDeviceKind .trackpad) {
615
- isLegalGesture = false ;
616
- return ;
617
- } else {
618
- isLegalGesture = true ;
619
- }
625
+ // if (event.kind == PointerDeviceKind.trackpad) {
626
+ // isLegalGesture = false;
627
+ // return;
628
+ // } else {
629
+ // isLegalGesture = true;
630
+ // }
620
631
621
632
controller.onRotateStart (initialPos);
622
633
widget.onRotationStart? .call (handle, event);
623
634
}
624
635
625
636
void onHandleRotateUpdate (DragUpdateDetails event, HandlePosition handle) {
626
- if (! isLegalGesture) return ;
637
+ if (! isGestureActive) return ;
638
+
627
639
final offset =
628
640
widget.handleAlignment.offset (widget.rotationHandleGestureSize);
629
641
localPos = rectQuadrantOffset (handle.quadrant) +
@@ -659,7 +671,10 @@ class _TransformableBoxState extends State<TransformableBox> {
659
671
}
660
672
661
673
void onHandleRotateEnd (DragEndDetails event, HandlePosition handle) {
662
- if (! isLegalGesture) return ;
674
+ if (! isGestureActive) return ;
675
+
676
+ primaryGestureOperation = null ;
677
+ lastHandle = null ;
663
678
664
679
controller.onRotateEnd ();
665
680
widget.onRotationEnd? .call (handle, event);
@@ -673,7 +688,10 @@ class _TransformableBoxState extends State<TransformableBox> {
673
688
}
674
689
675
690
void onHandleRotateCancel (HandlePosition handle) {
676
- if (! isLegalGesture) return ;
691
+ if (! isGestureActive) return ;
692
+
693
+ primaryGestureOperation = null ;
694
+ lastHandle = null ;
677
695
678
696
controller.onRotateEnd ();
679
697
widget.onRotationCancel? .call (handle);
@@ -832,7 +850,8 @@ class _TransformableBoxState extends State<TransformableBox> {
832
850
resizeHandleGestureSize: widget.resizeHandleGestureSize,
833
851
rotationHandleGestureSize:
834
852
widget.rotationHandleGestureSize,
835
- supportedDevices: widget.supportedResizeDevices,enabled: widget.enabledHandles.contains (handle),
853
+ supportedDevices: widget.supportedResizeDevices,
854
+ enabled: widget.enabledHandles.contains (handle),
836
855
visible: widget.visibleHandles.contains (handle),
837
856
rotatable: widget.rotatable,
838
857
// Resize
@@ -862,7 +881,7 @@ class _TransformableBoxState extends State<TransformableBox> {
862
881
rotationHandleGestureSize:
863
882
widget.rotationHandleGestureSize,
864
883
rotatable: widget.rotatable,
865
- supportedDevices: widget.supportedResizeDevices,
884
+ supportedDevices: widget.supportedResizeDevices,
866
885
enabled: widget.enabledHandles.contains (handle),
867
886
visible: widget.visibleHandles.contains (handle),
868
887
onPanStart: (event) => onHandlePanStart (event, handle),
0 commit comments