1+ import 'package:flutter/gestures.dart' ;
12import 'package:flutter/material.dart' ;
23
34import '../flutter_box_transform.dart' ;
@@ -66,6 +67,16 @@ class TransformableBox extends StatefulWidget {
6667 /// visible, it will not be shown and will not be interactive.
6768 final Set <HandlePosition > visibleHandles;
6869
70+ /// The kind of devices that are allowed to be recognized for drag events.
71+ ///
72+ /// By default, events from all device types will be recognized for drag events.
73+ final Set <PointerDeviceKind > supportedDragDevices;
74+
75+ /// The kind of devices that are allowed to be recognized for resize events.
76+ ///
77+ /// By default, events from all device types will be recognized for resize events.
78+ final Set <PointerDeviceKind > supportedResizeDevices;
79+
6980 /// The initial box that will be used to position set the initial size of
7081 /// the [TransformableBox] widget.
7182 ///
@@ -231,6 +242,8 @@ class TransformableBox extends StatefulWidget {
231242 this .handleAlignment = HandleAlignment .center,
232243 this .enabledHandles = const {...HandlePosition .values},
233244 this .visibleHandles = const {...HandlePosition .values},
245+ this .supportedDragDevices = const {...PointerDeviceKind .values},
246+ this .supportedResizeDevices = const {...PointerDeviceKind .values},
234247
235248 // Raw values.
236249 Rect ? rect,
@@ -576,6 +589,7 @@ class _TransformableBoxState extends State<TransformableBox> {
576589 if (widget.draggable) {
577590 content = GestureDetector (
578591 behavior: HitTestBehavior .translucent,
592+ supportedDevices: widget.supportedDragDevices,
579593 onTap: onTap,
580594 onPanStart: onDragPanStart,
581595 onPanUpdate: onDragPanUpdate,
@@ -606,6 +620,7 @@ class _TransformableBoxState extends State<TransformableBox> {
606620 key: ValueKey (handle),
607621 handlePosition: handle,
608622 handleTapSize: widget.handleTapSize,
623+ supportedDevices: widget.supportedResizeDevices,
609624 enabled: widget.enabledHandles.contains (handle),
610625 visible: widget.visibleHandles.contains (handle),
611626 onPanStart: (event) => onHandlePanStart (event, handle),
@@ -622,6 +637,7 @@ class _TransformableBoxState extends State<TransformableBox> {
622637 key: ValueKey (handle),
623638 handlePosition: handle,
624639 handleTapSize: widget.handleTapSize,
640+ supportedDevices: widget.supportedResizeDevices,
625641 enabled: widget.enabledHandles.contains (handle),
626642 visible: widget.visibleHandles.contains (handle),
627643 onPanStart: (event) => onHandlePanStart (event, handle),
0 commit comments