Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Flutter
  2. widgets.dart
  3. Draggable<T extendsObject> class
Draggable
description

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.

The following example has aDraggable widget along with aDragTargetin a row demonstrating an incrementedacceptedData integer value whenyou drag the element to the target.
link

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

affinityAxis?
Controls how this widget competes with other gestures to initiate a drag.
final
allowedButtonsFilterAllowedButtonsFilter?
Called when interaction starts. This limits the dragging behaviorfor custom clicks (such as scroll click). Its parameter comesfromPointerEvent.buttons.
final
axisAxis?
TheAxis to restrict this draggable's movement, if specified.
final
childWidget
The widget below this widget in the tree.
final
childWhenDraggingWidget?
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
dragAnchorStrategyDragAnchorStrategy
A strategy that is used by this draggable to get the anchor offset when itis dragged.
final
feedbackWidget
The widget to show under the pointer when a drag is under way.
final
feedbackOffsetOffset
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
hashCodeint
The hash code for this object.
no setterinherited
hitTestBehaviorHitTestBehavior
How to behave during hit test.
final
ignoringFeedbackPointerbool
Whether thefeedback widget is ignored during hit testing.
final
ignoringFeedbackSemanticsbool
Whether the semantics of thefeedback widget is ignored when buildingthe semantics tree.
final
keyKey?
Controls how one widget replaces another widget in the tree.
finalinherited
maxSimultaneousDragsint?
How many simultaneous drags to support.
final
onDragCompletedVoidCallback?
Called when the draggable is dropped and accepted by aDragTarget.
final
onDragEndDragEndCallback?
Called when the draggable is dropped.
final
onDraggableCanceledDraggableCanceledCallback?
Called when the draggable is dropped without being accepted by aDragTarget.
final
onDragStartedVoidCallback?
Called when the draggable starts being dragged.
final
onDragUpdateDragUpdateCallback?
Called when the draggable is dragged.
final
rootOverlaybool
Whether the feedback widget will be put on the rootOverlay.
final
runtimeTypeType
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
  1. Flutter
  2. widgets
  3. Draggable<T extendsObject> class
widgets library

[8]ページ先頭

©2009-2026 Movatter.jp