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
/// If feedback is identical to the child, then this means the feedback will
/// 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:
///
......@@ -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
/// the child and not the finger.)
///
/// This replaces [DragAnchor.pointer], which has been deprecated.
///
/// See also:
///
/// * [DragAnchorStrategy], the typedef that this function implements.
......@@ -120,34 +118,6 @@ Offset pointerDragAnchorStrategy(Draggable<Object> draggable, BuildContext conte
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].
///
/// When a draggable widget recognizes the start of a drag gesture, it displays
......@@ -197,14 +167,7 @@ class Draggable<T extends Object> extends StatefulWidget {
this.axis,
this.childWhenDragging,
this.feedbackOffset = Offset.zero,
@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.',
)
this.dragAnchor = DragAnchor.child,
this.dragAnchorStrategy,
this.dragAnchorStrategy = childDragAnchorStrategy,
this.affinity,
this.maxSimultaneousDrags,
this.onDragStarted,
......@@ -220,7 +183,8 @@ class Draggable<T extends Object> extends StatefulWidget {
assert(feedback != null),
assert(ignoringFeedbackSemantics != 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.
final T? data;
......@@ -276,17 +240,6 @@ class Draggable<T extends Object> extends StatefulWidget {
/// is transformed compared to the child.
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
/// is dragged.
///
......@@ -302,10 +255,8 @@ class Draggable<T extends Object> extends StatefulWidget {
/// * [pointerDragAnchorStrategy], which displays the feedback anchored at the
/// position of the touch that started the drag.
///
/// Defaults to [childDragAnchorStrategy] if the deprecated [dragAnchor]
/// property is set to [DragAnchor.child], and [pointerDragAnchorStrategy] if
/// the [dragAnchor] is set to [DragAnchor.pointer].
final DragAnchorStrategy? dragAnchorStrategy;
/// Defaults to [childDragAnchorStrategy].
final DragAnchorStrategy dragAnchorStrategy;
/// Whether the semantics of the [feedback] widget is ignored when building
/// the semantics tree.
......@@ -447,13 +398,6 @@ class LongPressDraggable<T extends Object> extends Draggable<T> {
super.axis,
super.childWhenDragging,
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.maxSimultaneousDrags,
super.onDragStarted,
......@@ -539,18 +483,7 @@ class _DraggableState<T extends Object> extends State<Draggable<T>> {
return null;
}
final Offset dragStartPoint;
if (widget.dragAnchorStrategy == null) {
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);
}
dragStartPoint = widget.dragAnchorStrategy(widget, context, position);
setState(() {
_activeCount += 1;
});
......
......@@ -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).child, widget1);
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);
});
}
......
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