diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index 40ddc58e1b..259603dc12 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -86,7 +86,7 @@ typedef DragAnchorStrategy = Offset Function(Draggable 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 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 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 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 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 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 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 extends Draggable { 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 extends State> { 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; }); diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index c12c09511b..db14222b6e 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -3192,8 +3192,6 @@ void main() { expect(const LongPressDraggable(feedback: widget2, child: widget1), isA>()); expect(const LongPressDraggable(feedback: widget2, child: widget1).child, widget1); expect(const LongPressDraggable(feedback: widget2, child: widget1).feedback, widget2); - expect(const LongPressDraggable(feedback: widget2, child: widget1).dragAnchor, DragAnchor.child); - expect(const LongPressDraggable(feedback: widget2, dragAnchor: DragAnchor.pointer, child: widget1).dragAnchor, DragAnchor.pointer); expect(LongPressDraggable(feedback: widget2, dragAnchorStrategy: dummyStrategy, child: widget1).dragAnchorStrategy, dummyStrategy); }); }