Skip to content

Commit 8ce76ed

Browse files
eseidelBuchimi
authored andcommitted
Add more docs to DragTraget.builder (flutter#151447)
Clarifications and changing a reference to a deprecated member.
1 parent 7ede8c0 commit 8ce76ed

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

packages/flutter/lib/src/widgets/drag_target.dart

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ typedef DragTargetAcceptWithDetails<T> = void Function(DragTargetDetails<T> deta
3939
/// Signature for building children of a [DragTarget].
4040
///
4141
/// The `candidateData` argument contains the list of drag data that is hovering
42-
/// over this [DragTarget] and that has passed [DragTarget.onWillAccept]. The
43-
/// `rejectedData` argument contains the list of drag data that is hovering over
44-
/// this [DragTarget] and that will not be accepted by the [DragTarget].
42+
/// over this [DragTarget] and that has passed
43+
/// [DragTarget.onWillAcceptWithDetails]. The `rejectedData` argument contains
44+
/// the list of drag data that is hovering over this [DragTarget] and that will
45+
/// not be accepted by the [DragTarget].
4546
///
4647
/// Used by [DragTarget.builder].
4748
typedef DragTargetBuilder<T> = Widget Function(BuildContext context, List<T?> candidateData, List<dynamic> rejectedData);
@@ -633,6 +634,20 @@ class DragTarget<T extends Object> extends StatefulWidget {
633634
///
634635
/// The builder can build different widgets depending on what is being dragged
635636
/// into this drag target.
637+
///
638+
/// [onWillAccept] or [onWillAcceptWithDetails] is called when a draggable
639+
/// enters the target. If true, then the data will appear in `candidateData`,
640+
/// else in `rejectedData`.
641+
///
642+
/// Typically the builder will check `candidateData` and `rejectedData` and
643+
/// build a widget that indicates the result of dropping the `candidateData`
644+
/// onto this target.
645+
///
646+
/// The `candidateData` and `rejectedData` are [List] types to support multiple
647+
/// simultaneous drags.
648+
///
649+
/// If unexpected `null` values in `candidateData` or `rejectedData`, ensure
650+
/// that the `data` argument of the [Draggable] is not `null`.
636651
final DragTargetBuilder<T> builder;
637652

638653
/// Called to determine whether this widget is interested in receiving a given

0 commit comments

Comments
 (0)