From 099c884985c2ebfe97f86e7eb7827602db8f6de1 Mon Sep 17 00:00:00 2001 From: Anders Klint <anders.klint519@gmail.com> Date: Sat, 22 Mar 2025 11:46:50 +0100 Subject: [PATCH 1/2] feat: add tapThrough property to allow tap passthrough --- .../flutter_box_transform/lib/src/transformable_box.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/flutter_box_transform/lib/src/transformable_box.dart b/packages/flutter_box_transform/lib/src/transformable_box.dart index 92f57ac..47892d8 100644 --- a/packages/flutter_box_transform/lib/src/transformable_box.dart +++ b/packages/flutter_box_transform/lib/src/transformable_box.dart @@ -125,6 +125,10 @@ class TransformableBox extends StatefulWidget { /// all moving operations. final bool draggable; + /// Whether the box ignores tap events and allows them to pass through to widgets + /// behind it. Dragging and resizing interactions are still possible. + final bool tapThrough; + /// Whether to allow flipping of the box while resizing. If this is set to /// true, the box will flip when the user drags the handles to opposite /// corners of the rect. @@ -255,6 +259,7 @@ class TransformableBox extends StatefulWidget { // Additional controls. this.resizable = true, this.draggable = true, + this.tapThrough = false, this.allowFlippingWhileResizing = true, // Tap events @@ -597,7 +602,7 @@ class _TransformableBoxState extends State<TransformableBox> { content = GestureDetector( behavior: HitTestBehavior.translucent, supportedDevices: widget.supportedDragDevices, - onTap: onTap, + onTap: widget.tapThrough ? null : onTap, onPanStart: onDragPanStart, onPanUpdate: onDragPanUpdate, onPanEnd: onDragPanEnd, From e5c3f8f4052ef02e9497e4d905d03a8c12eaf56b Mon Sep 17 00:00:00 2001 From: Anders Klint <anders.klint519@gmail.com> Date: Sat, 22 Mar 2025 12:24:22 +0100 Subject: [PATCH 2/2] tap through box if onTap is null --- .../flutter_box_transform/lib/src/transformable_box.dart | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/flutter_box_transform/lib/src/transformable_box.dart b/packages/flutter_box_transform/lib/src/transformable_box.dart index 47892d8..2c9a296 100644 --- a/packages/flutter_box_transform/lib/src/transformable_box.dart +++ b/packages/flutter_box_transform/lib/src/transformable_box.dart @@ -125,10 +125,6 @@ class TransformableBox extends StatefulWidget { /// all moving operations. final bool draggable; - /// Whether the box ignores tap events and allows them to pass through to widgets - /// behind it. Dragging and resizing interactions are still possible. - final bool tapThrough; - /// Whether to allow flipping of the box while resizing. If this is set to /// true, the box will flip when the user drags the handles to opposite /// corners of the rect. @@ -259,7 +255,6 @@ class TransformableBox extends StatefulWidget { // Additional controls. this.resizable = true, this.draggable = true, - this.tapThrough = false, this.allowFlippingWhileResizing = true, // Tap events @@ -602,7 +597,7 @@ class _TransformableBoxState extends State<TransformableBox> { content = GestureDetector( behavior: HitTestBehavior.translucent, supportedDevices: widget.supportedDragDevices, - onTap: widget.tapThrough ? null : onTap, + onTap: widget.onTap == null ? null : onTap, onPanStart: onDragPanStart, onPanUpdate: onDragPanUpdate, onPanEnd: onDragPanEnd,