pub struct Draggable<T: 'static> {Show 20 fields
pub key: Option<KeyRef>,
pub data: Option<Rc<T>>,
pub axis: Option<Axis>,
pub child: WidgetRef,
pub child_when_dragging: Option<WidgetRef>,
pub feedback: WidgetRef,
pub feedback_offset: Offset,
pub drag_anchor_strategy: DragAnchorStrategy<T>,
pub ignoring_feedback_semantics: bool,
pub ignoring_feedback_pointer: bool,
pub affinity: Option<Axis>,
pub max_simultaneous_drags: Option<usize>,
pub on_drag_started: Option<Listener>,
pub on_drag_update: Option<DragUpdateCallback>,
pub on_draggable_canceled: Option<DraggableCanceledCallback>,
pub on_drag_completed: Option<Listener>,
pub on_drag_end: Option<DragEndCallback>,
pub root_overlay: bool,
pub hit_test_behavior: HitTestBehavior,
pub allowed_buttons_filter: Option<AllowedButtonsFilter>,
}Expand description
A widget that can be dragged from to a DragTarget.
Active drags and their feedback survive removal of the source widget.
Fields§
§key: Option<KeyRef>Controls how one widget replaces another widget in the tree.
data: Option<Rc<T>>The data that was dropped onto this DragTarget.
axis: Option<Axis>The Axis to restrict this draggable’s movement, if specified.
When axis is set to Axis.horizontal, this widget can only be dragged
horizontally. Behavior is similar for Axis.vertical.
Defaults to allowing drag on both Axis.horizontal and Axis.vertical.
When null, allows drag on both Axis.horizontal and Axis.vertical.
For the direction of gestures this widget competes with to start a drag
event, see Draggable.affinity.
child: WidgetRefThe widget below this widget in the tree.
This widget displays child when zero drags are under way. If
childWhenDragging is non-null, this widget instead displays
childWhenDragging when one or more drags are underway. Otherwise, this
widget always displays child.
The feedback widget is shown under the pointer when a drag is under way.
To limit the number of simultaneous drags on multitouch devices, see
maxSimultaneousDrags.
{@macro flutter.widgets.ProxyWidget.child}
child_when_dragging: Option<WidgetRef>The widget to display instead of child when one or more drags are under way.
If this is null, then this widget will always display child (and so the
drag source representation will not change while a drag is under
way).
The feedback widget is shown under the pointer when a drag is under way.
To limit the number of simultaneous drags on multitouch devices, see
maxSimultaneousDrags.
feedback: WidgetRefThe widget to show under the pointer when a drag is under way.
See child and childWhenDragging for information about what is shown
at the location of the Draggable itself when a drag is under way.
feedback_offset: OffsetThe feedbackOffset can be used to set the hit test target point for the purposes of finding a drag target. It is especially useful if the feedback is transformed compared to the child.
drag_anchor_strategy: DragAnchorStrategy<T>A strategy that is used by this draggable to get the anchor offset when it is dragged.
The anchor offset refers to the distance between the users’ fingers and
the feedback widget when this draggable is dragged.
This property’s value is a function that implements DragAnchorStrategy.
There are two built-in functions that can be used:
-
childDragAnchorStrategy, which displays the feedback anchored at the position of the original child. -
pointerDragAnchorStrategy, which displays the feedback anchored at the position of the touch that started the drag.
Defaults to childDragAnchorStrategy.
ignoring_feedback_semantics: boolWhether the semantics of the feedback widget is ignored when building
the semantics tree.
This value should be set to false when the feedback widget is intended
to be the same object as the child. Placing a GlobalKey on this
widget will ensure semantic focus is kept on the element as it moves in
and out of the feedback position.
Defaults to true.
ignoring_feedback_pointer: boolWhether the feedback widget is ignored during hit testing.
Regardless of whether this widget is ignored during hit testing, it will still consume space during layout and be visible during painting.
Defaults to true.
affinity: Option<Axis>Controls how this widget competes with other gestures to initiate a drag.
If affinity is null, this widget initiates a drag as soon as it recognizes a tap down gesture, regardless of any directionality. If affinity is horizontal (or vertical), then this widget will compete with other horizontal (or vertical, respectively) gestures.
For example, if this widget is placed in a vertically scrolling region and
has horizontal affinity, pointer motion in the vertical direction will
result in a scroll and pointer motion in the horizontal direction will
result in a drag. Conversely, if the widget has a null or vertical
affinity, pointer motion in any direction will result in a drag rather
than in a scroll because the draggable widget, being the more specific
widget, will out-compete the Scrollable for vertical gestures.
For the directions this widget can be dragged in after the drag event
starts, see Draggable.axis.
max_simultaneous_drags: Option<usize>How many simultaneous drags to support.
When null, no limit is applied. Set this to 1 if you want to only allow the drag source to have one item dragged at a time. Set this to 0 if you want to prevent the draggable from actually being dragged.
If you set this property to 1, consider supplying an “empty” widget for
childWhenDragging to create the illusion of actually moving child.
on_drag_started: Option<Listener>Called when the draggable starts being dragged.
on_drag_update: Option<DragUpdateCallback>Called when the draggable is dragged.
This function will only be called while this widget is still mounted to
the tree (i.e. State.mounted is true), and if this widget has actually moved.
on_draggable_canceled: Option<DraggableCanceledCallback>Called when the draggable is dropped without being accepted by a DragTarget.
This function might be called after this widget has been removed from the
tree. For example, if a drag was in progress when this widget was removed
from the tree and the drag ended up being canceled, this callback will
still be called. For this reason, implementations of this callback might
need to check State.mounted to check whether the state receiving the
callback is still in the tree.
on_drag_completed: Option<Listener>Called when the draggable is dropped and accepted by a DragTarget.
This function might be called after this widget has been removed from the
tree. For example, if a drag was in progress when this widget was removed
from the tree and the drag ended up completing, this callback will
still be called. For this reason, implementations of this callback might
need to check State.mounted to check whether the state receiving the
callback is still in the tree.
on_drag_end: Option<DragEndCallback>Called when the draggable is dropped.
The velocity and offset at which the pointer was moving when it was
dropped is available in the DraggableDetails. Also included in the
details is whether the draggable’s DragTarget accepted it.
This function will only be called while this widget is still mounted to
the tree (i.e. State.mounted is true).
root_overlay: boolWhether the feedback widget will be put on the root Overlay.
When false, the feedback widget will be put on the closest Overlay. When
true, the feedback widget will be put on the farthest (aka root)
Overlay.
Defaults to false.
hit_test_behavior: HitTestBehaviorHow to behave during hit testing.
Defaults to HitTestBehavior.translucent.
{@macro flutter.gestures.multidrag._allowedButtonsFilter}
Implementations§
Source§impl<T: 'static> Draggable<T>
impl<T: 'static> Draggable<T>
Sourcepub fn new<C, F>(
child: impl IntoWidget<C>,
feedback: impl IntoWidget<F>,
) -> Self
pub fn new<C, F>( child: impl IntoWidget<C>, feedback: impl IntoWidget<F>, ) -> Self
Creates a draggable with its normal child and drag feedback.
Sourcepub fn child_when_dragging<K>(self, value: impl IntoWidget<K>) -> Self
pub fn child_when_dragging<K>(self, value: impl IntoWidget<K>) -> Self
Sets child_when_dragging for this draggable.
Sourcepub fn feedback_offset(self, value: Offset) -> Self
pub fn feedback_offset(self, value: Offset) -> Self
Sets feedback_offset for this draggable.
Sourcepub fn drag_anchor_strategy(self, value: DragAnchorStrategy<T>) -> Self
pub fn drag_anchor_strategy(self, value: DragAnchorStrategy<T>) -> Self
Sets drag_anchor_strategy for this draggable.
Sourcepub fn ignoring_feedback_semantics(self, value: bool) -> Self
pub fn ignoring_feedback_semantics(self, value: bool) -> Self
Sets ignoring_feedback_semantics for this draggable.
Sourcepub fn ignoring_feedback_pointer(self, value: bool) -> Self
pub fn ignoring_feedback_pointer(self, value: bool) -> Self
Sets ignoring_feedback_pointer for this draggable.
Sourcepub fn max_simultaneous_drags(self, value: usize) -> Self
pub fn max_simultaneous_drags(self, value: usize) -> Self
Sets max_simultaneous_drags for this draggable.
Sourcepub fn on_drag_started(self, value: Listener) -> Self
pub fn on_drag_started(self, value: Listener) -> Self
Sets on_drag_started for this draggable.
Sourcepub fn on_drag_update(self, value: DragUpdateCallback) -> Self
pub fn on_drag_update(self, value: DragUpdateCallback) -> Self
Sets on_drag_update for this draggable.
Sourcepub fn on_draggable_canceled(self, value: DraggableCanceledCallback) -> Self
pub fn on_draggable_canceled(self, value: DraggableCanceledCallback) -> Self
Sets on_draggable_canceled for this draggable.
Sourcepub fn on_drag_completed(self, value: Listener) -> Self
pub fn on_drag_completed(self, value: Listener) -> Self
Sets on_drag_completed for this draggable.
Sourcepub fn on_drag_end(self, value: DragEndCallback) -> Self
pub fn on_drag_end(self, value: DragEndCallback) -> Self
Sets on_drag_end for this draggable.
Sourcepub fn root_overlay(self, value: bool) -> Self
pub fn root_overlay(self, value: bool) -> Self
Sets root_overlay for this draggable.
Sourcepub fn hit_test_behavior(self, value: HitTestBehavior) -> Self
pub fn hit_test_behavior(self, value: HitTestBehavior) -> Self
Sets hit_test_behavior for this draggable.
Sets allowed_buttons_filter for this draggable.
Trait Implementations§
Source§impl<T: 'static> DraggableWidget for Draggable<T>
impl<T: 'static> DraggableWidget for Draggable<T>
type Data = T
fn draggable(&self) -> &Self
fn create_recognizer( &self, app: &mut App, on_start: GestureMultiDragStartCallback, ) -> MultiDragRecognizerRef
Source§impl<T: 'static> StatefulWidget for Draggable<T>
impl<T: 'static> StatefulWidget for Draggable<T>
Source§type State = DraggableState<Draggable<T>>
type State = DraggableState<Draggable<T>>
Source§fn create_state(&self) -> Self::State
fn create_state(&self) -> Self::State
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl<T> !RefUnwindSafe for Draggable<T>
impl<T> !Send for Draggable<T>
impl<T> !Sync for Draggable<T>
impl<T> !UnwindSafe for Draggable<T>
impl<T> Forget for Draggable<T>
impl<T> Freeze for Draggable<T>where
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<T> is !null: Freeze,
PhantomData<RcInner<T>>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
*const RcInner<dyn Fn(&mut App, &Draggable<T>, AnyElement, Offset) -> Offset> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, &Draggable<T>, AnyElement, Offset) -> Offset>>: Freeze,
*const RcInner<dyn Fn(&mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze,
NonZero<u32>: Freeze,
*const (): Freeze,
*const RcInner<dyn Fn(&mut App, DragUpdateDetails)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, DragUpdateDetails)>>: Freeze,
*const RcInner<dyn Fn(&mut App, Velocity, Offset)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, Velocity, Offset)>>: Freeze,
*const RcInner<dyn Fn(&mut App, DraggableDetails)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, DraggableDetails)>>: Freeze,
*const RcInner<dyn Fn(i64) -> bool> is !null: Freeze,
PhantomData<RcInner<dyn Fn(i64) -> bool>>: Freeze,
impl<T> Move for Draggable<T>
impl<T> Unpin for Draggable<T>where
Rc<dyn Key>: Unpin,
Rc<T>: Unpin,
Rc<dyn Widget>: Unpin,
Rc<dyn Fn(&mut App, &Draggable<T>, AnyElement, Offset) -> Offset>: Unpin,
Rc<dyn Fn(&mut App)>: Unpin,
NonZero<u32>: Unpin,
*const (): Unpin,
Rc<dyn Fn(&mut App, DragUpdateDetails)>: Unpin,
Rc<dyn Fn(&mut App, Velocity, Offset)>: Unpin,
Rc<dyn Fn(&mut App, DraggableDetails)>: Unpin,
Rc<dyn Fn(i64) -> bool>: Unpin,
impl<T> UnsafeUnpin for Draggable<T>where
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<T> is !null: UnsafeUnpin,
PhantomData<RcInner<T>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, &Draggable<T>, AnyElement, Offset) -> Offset> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, &Draggable<T>, AnyElement, Offset) -> Offset>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, DragUpdateDetails)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, DragUpdateDetails)>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, Velocity, Offset)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, Velocity, Offset)>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, DraggableDetails)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, DraggableDetails)>>: UnsafeUnpin,
*const RcInner<dyn Fn(i64) -> bool> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(i64) -> bool>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.