Draggable<T extends Object> class
A widget that can be dragged from to aDragTarget.
When a draggable widget recognizes the start of a drag gesture, it displaysafeedback widget that tracks the user's finger across the screen. If theuser lifts their finger while on top of aDragTarget, that target is giventhe opportunity to accept thedata carried by the draggable.
TheignoringFeedbackPointer defaults to true, which means thatthefeedback widget ignores the pointer during hit testing. Similarly,ignoringFeedbackSemantics defaults to true, and thefeedback also ignoressemantics when building the semantics tree.
On multitouch devices, multiple drags can occur simultaneously because therecan be multiple pointers in contact with the device at once. To limit thenumber of simultaneous drags, use themaxSimultaneousDrags property. Thedefault is to allow an unlimited number of simultaneous drags.
This widget displayschild when zero drags are under way. IfchildWhenDragging is non-null, this widget instead displayschildWhenDragging when one or more drags are underway. Otherwise, thiswidget always displayschild.
acceptedData integer value whenyou drag the element to the target.To create a local project with this code sample, run:
flutter create --sample=widgets.Draggable.1 mysample
See also:
- Inheritance
- Implementers
Constructors
- Draggable({Key?key,requiredWidgetchild,requiredWidgetfeedback,T?data,Axis?axis,Widget?childWhenDragging,OffsetfeedbackOffset =Offset.zero,DragAnchorStrategydragAnchorStrategy =childDragAnchorStrategy,Axis?affinity,int?maxSimultaneousDrags,VoidCallback?onDragStarted,DragUpdateCallback?onDragUpdate,DraggableCanceledCallback?onDraggableCanceled,DragEndCallback?onDragEnd,VoidCallback?onDragCompleted,boolignoringFeedbackSemantics =true,boolignoringFeedbackPointer =true,boolrootOverlay =false,HitTestBehaviorhitTestBehavior =HitTestBehavior.deferToChild,AllowedButtonsFilter?allowedButtonsFilter})
- Creates a widget that can be dragged to aDragTarget.const
Properties
- affinity→Axis?
- Controls how this widget competes with other gestures to initiate a drag.final
- allowedButtonsFilter→AllowedButtonsFilter?
- Called when interaction starts. This limits the dragging behaviorfor custom clicks (such as scroll click). Its parameter comesfromPointerEvent.buttons.final
- axis→Axis?
- TheAxis to restrict this draggable's movement, if specified.final
- child→Widget
- The widget below this widget in the tree.final
- childWhenDragging→Widget?
- The widget to display instead ofchild when one or more drags are under way.final
- data→ T?
- The data that will be dropped by this draggable.final
- dragAnchorStrategy→DragAnchorStrategy
- A strategy that is used by this draggable to get the anchor offset when itis dragged.final
- feedback→Widget
- The widget to show under the pointer when a drag is under way.final
- feedbackOffset→Offset
- The feedbackOffset can be used to set the hit test target point for thepurposes of finding a drag target. It is especially useful if the feedbackis transformed compared to the child.final
- hashCode→int
- The hash code for this object.no setterinherited
- hitTestBehavior→HitTestBehavior
- How to behave during hit test.final
- ignoringFeedbackPointer→bool
- Whether thefeedback widget is ignored during hit testing.final
- ignoringFeedbackSemantics→bool
- Whether the semantics of thefeedback widget is ignored when buildingthe semantics tree.final
- key→Key?
- Controls how one widget replaces another widget in the tree.finalinherited
- maxSimultaneousDrags→int?
- How many simultaneous drags to support.final
- onDragCompleted→VoidCallback?
- Called when the draggable is dropped and accepted by aDragTarget.final
- onDragEnd→DragEndCallback?
- Called when the draggable is dropped.final
- onDraggableCanceled→DraggableCanceledCallback?
- Called when the draggable is dropped without being accepted by aDragTarget.final
- onDragStarted→VoidCallback?
- Called when the draggable starts being dragged.final
- onDragUpdate→DragUpdateCallback?
- Called when the draggable is dragged.final
- rootOverlay→bool
- Whether the feedback widget will be put on the rootOverlay.final
- runtimeType→Type
- A representation of the runtime type of the object.no setterinherited
Methods
- createElement(
)→StatefulElement - Creates aStatefulElement to manage this widget's location in the tree.inherited
- createRecognizer(
GestureMultiDragStartCallbackonStart)→MultiDragGestureRecognizer - Creates a gesture recognizer that recognizes the start of the drag.
- createState(
)→State< Draggable< T> > - Creates the mutable state for this widget at a given location in the tree.override
- debugDescribeChildren(
)→List< DiagnosticsNode> - Returns a list ofDiagnosticsNode objects describing this node'schildren.inherited
- debugFillProperties(
DiagnosticPropertiesBuilderproperties)→ void - Add additional properties associated with the node.inherited
- noSuchMethod(
Invocationinvocation)→ dynamic - Invoked when a nonexistent method or property is accessed.inherited
- toDiagnosticsNode(
{String?name,DiagnosticsTreeStyle?style})→DiagnosticsNode - Returns a debug representation of the object that is used by debuggingtools and byDiagnosticsNode.toStringDeep.inherited
- toString(
{DiagnosticLevelminLevel =DiagnosticLevel.info})→String - A string representation of this object.inherited
- toStringDeep(
{StringprefixLineOne ='',String?prefixOtherLines,DiagnosticLevelminLevel =DiagnosticLevel.debug,intwrapWidth =65})→String - Returns a string representation of this node and its descendants.inherited
- toStringShallow(
{Stringjoiner =', ',DiagnosticLevelminLevel =DiagnosticLevel.debug})→String - Returns a one-line detailed description of the object.inherited
- toStringShort(
)→String - A short, textual description of this widget.inherited
Operators
- operator ==(
Objectother)→bool - The equality operator.inherited