Unverified Commit 75d8fb36 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Remove deprecated drag anchor (#111713)

parent 55ad0ab1
...@@ -86,7 +86,7 @@ typedef DragAnchorStrategy = Offset Function(Draggable<Object> draggable, BuildC ...@@ -86,7 +86,7 @@ typedef DragAnchorStrategy = Offset Function(Draggable<Object> draggable, BuildC
/// If feedback is identical to the child, then this means the feedback will /// If feedback is identical to the child, then this means the feedback will
/// exactly overlap the original child when the drag starts. /// exactly overlap the original child when the drag starts.
/// ///
/// This is the default [DragAnchorStrategy] and replaces [DragAnchor.child]. /// This is the default [DragAnchorStrategy].
/// ///
/// See also: /// See also:
/// ///
...@@ -110,8 +110,6 @@ Offset childDragAnchorStrategy(Draggable<Object> draggable, BuildContext context ...@@ -110,8 +110,6 @@ Offset childDragAnchorStrategy(Draggable<Object> draggable, BuildContext context
/// weird for it to appear offset from the original child if it's anchored to /// weird for it to appear offset from the original child if it's anchored to
/// the child and not the finger.) /// the child and not the finger.)
/// ///
/// This replaces [DragAnchor.pointer], which has been deprecated.
///
/// See also: /// See also:
/// ///
/// * [DragAnchorStrategy], the typedef that this function implements. /// * [DragAnchorStrategy], the typedef that this function implements.
...@@ -120,34 +118,6 @@ Offset pointerDragAnchorStrategy(Draggable<Object> draggable, BuildContext conte ...@@ -120,34 +118,6 @@ Offset pointerDragAnchorStrategy(Draggable<Object> draggable, BuildContext conte
return Offset.zero; return Offset.zero;
} }
/// Where the [Draggable] should be anchored during a drag.
///
/// This has been replaced by the more configurable [DragAnchorStrategy].
@Deprecated(
'Use dragAnchorStrategy instead. '
'This feature was deprecated after v2.1.0-10.0.pre.',
)
enum DragAnchor {
/// Display the feedback anchored at the position of the original child.
///
/// Replaced by [childDragAnchorStrategy].
@Deprecated(
'Use childDragAnchorStrategy instead. '
'This feature was deprecated after v2.1.0-10.0.pre.',
)
child,
/// Display the feedback anchored at the position of the touch that started
/// the drag.
///
/// Replaced by [pointerDragAnchorStrategy].
@Deprecated(
'Use pointerDragAnchorStrategy instead. '
'This feature was deprecated after v2.1.0-10.0.pre.',
)
pointer,
}
/// A widget that can be dragged from to a [DragTarget]. /// A widget that can be dragged from to a [DragTarget].
/// ///
/// When a draggable widget recognizes the start of a drag gesture, it displays /// When a draggable widget recognizes the start of a drag gesture, it displays
...@@ -197,14 +167,7 @@ class Draggable<T extends Object> extends StatefulWidget { ...@@ -197,14 +167,7 @@ class Draggable<T extends Object> extends StatefulWidget {
this.axis, this.axis,
this.childWhenDragging, this.childWhenDragging,
this.feedbackOffset = Offset.zero, this.feedbackOffset = Offset.zero,
@Deprecated( this.dragAnchorStrategy = childDragAnchorStrategy,
'Use dragAnchorStrategy instead. '
'Replace "dragAnchor: DragAnchor.child" with "dragAnchorStrategy: childDragAnchorStrategy". '
'Replace "dragAnchor: DragAnchor.pointer" with "dragAnchorStrategy: pointerDragAnchorStrategy". '
'This feature was deprecated after v2.1.0-10.0.pre.',
)
this.dragAnchor = DragAnchor.child,
this.dragAnchorStrategy,
this.affinity, this.affinity,
this.maxSimultaneousDrags, this.maxSimultaneousDrags,
this.onDragStarted, this.onDragStarted,
...@@ -220,7 +183,8 @@ class Draggable<T extends Object> extends StatefulWidget { ...@@ -220,7 +183,8 @@ class Draggable<T extends Object> extends StatefulWidget {
assert(feedback != null), assert(feedback != null),
assert(ignoringFeedbackSemantics != null), assert(ignoringFeedbackSemantics != null),
assert(ignoringFeedbackPointer != null), assert(ignoringFeedbackPointer != null),
assert(maxSimultaneousDrags == null || maxSimultaneousDrags >= 0); assert(maxSimultaneousDrags == null || maxSimultaneousDrags >= 0),
assert(dragAnchorStrategy != null);
/// The data that will be dropped by this draggable. /// The data that will be dropped by this draggable.
final T? data; final T? data;
...@@ -276,17 +240,6 @@ class Draggable<T extends Object> extends StatefulWidget { ...@@ -276,17 +240,6 @@ class Draggable<T extends Object> extends StatefulWidget {
/// is transformed compared to the child. /// is transformed compared to the child.
final Offset feedbackOffset; final Offset feedbackOffset;
/// Where this widget should be anchored during a drag.
///
/// This property is overridden by the [dragAnchorStrategy] if the latter is provided.
///
/// Defaults to [DragAnchor.child].
@Deprecated(
'Use dragAnchorStrategy instead. '
'This feature was deprecated after v2.1.0-10.0.pre.',
)
final DragAnchor dragAnchor;
/// A strategy that is used by this draggable to get the anchor offset when it /// A strategy that is used by this draggable to get the anchor offset when it
/// is dragged. /// is dragged.
/// ///
...@@ -302,10 +255,8 @@ class Draggable<T extends Object> extends StatefulWidget { ...@@ -302,10 +255,8 @@ class Draggable<T extends Object> extends StatefulWidget {
/// * [pointerDragAnchorStrategy], which displays the feedback anchored at the /// * [pointerDragAnchorStrategy], which displays the feedback anchored at the
/// position of the touch that started the drag. /// position of the touch that started the drag.
/// ///
/// Defaults to [childDragAnchorStrategy] if the deprecated [dragAnchor] /// Defaults to [childDragAnchorStrategy].
/// property is set to [DragAnchor.child], and [pointerDragAnchorStrategy] if final DragAnchorStrategy dragAnchorStrategy;
/// the [dragAnchor] is set to [DragAnchor.pointer].
final DragAnchorStrategy? dragAnchorStrategy;
/// Whether the semantics of the [feedback] widget is ignored when building /// Whether the semantics of the [feedback] widget is ignored when building
/// the semantics tree. /// the semantics tree.
...@@ -447,13 +398,6 @@ class LongPressDraggable<T extends Object> extends Draggable<T> { ...@@ -447,13 +398,6 @@ class LongPressDraggable<T extends Object> extends Draggable<T> {
super.axis, super.axis,
super.childWhenDragging, super.childWhenDragging,
super.feedbackOffset, super.feedbackOffset,
@Deprecated(
'Use dragAnchorStrategy instead. '
'Replace "dragAnchor: DragAnchor.child" with "dragAnchorStrategy: childDragAnchorStrategy". '
'Replace "dragAnchor: DragAnchor.pointer" with "dragAnchorStrategy: pointerDragAnchorStrategy". '
'This feature was deprecated after v2.1.0-10.0.pre.',
)
super.dragAnchor,
super.dragAnchorStrategy, super.dragAnchorStrategy,
super.maxSimultaneousDrags, super.maxSimultaneousDrags,
super.onDragStarted, super.onDragStarted,
...@@ -539,18 +483,7 @@ class _DraggableState<T extends Object> extends State<Draggable<T>> { ...@@ -539,18 +483,7 @@ class _DraggableState<T extends Object> extends State<Draggable<T>> {
return null; return null;
} }
final Offset dragStartPoint; final Offset dragStartPoint;
if (widget.dragAnchorStrategy == null) { dragStartPoint = widget.dragAnchorStrategy(widget, context, position);
switch (widget.dragAnchor) {
case DragAnchor.child:
dragStartPoint = childDragAnchorStrategy(widget, context, position);
break;
case DragAnchor.pointer:
dragStartPoint = pointerDragAnchorStrategy(widget, context, position);
break;
}
} else {
dragStartPoint = widget.dragAnchorStrategy!(widget, context, position);
}
setState(() { setState(() {
_activeCount += 1; _activeCount += 1;
}); });
......
...@@ -3192,8 +3192,6 @@ void main() { ...@@ -3192,8 +3192,6 @@ void main() {
expect(const LongPressDraggable<int>(feedback: widget2, child: widget1), isA<Draggable<int>>()); expect(const LongPressDraggable<int>(feedback: widget2, child: widget1), isA<Draggable<int>>());
expect(const LongPressDraggable<int>(feedback: widget2, child: widget1).child, widget1); expect(const LongPressDraggable<int>(feedback: widget2, child: widget1).child, widget1);
expect(const LongPressDraggable<int>(feedback: widget2, child: widget1).feedback, widget2); expect(const LongPressDraggable<int>(feedback: widget2, child: widget1).feedback, widget2);
expect(const LongPressDraggable<int>(feedback: widget2, child: widget1).dragAnchor, DragAnchor.child);
expect(const LongPressDraggable<int>(feedback: widget2, dragAnchor: DragAnchor.pointer, child: widget1).dragAnchor, DragAnchor.pointer);
expect(LongPressDraggable<int>(feedback: widget2, dragAnchorStrategy: dummyStrategy, child: widget1).dragAnchorStrategy, dummyStrategy); expect(LongPressDraggable<int>(feedback: widget2, dragAnchorStrategy: dummyStrategy, child: widget1).dragAnchorStrategy, dummyStrategy);
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment