From ee5c080d7b754177429b8559cbd006e88de8479c Mon Sep 17 00:00:00 2001 From: Jivansh Sharma Date: Mon, 2 Nov 2020 17:28:05 +0530 Subject: [PATCH] Update Draggable API Docs (#69527) --- .../flutter/lib/src/widgets/drag_target.dart | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index 0939767566a..a064d511f49 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -99,6 +99,73 @@ enum DragAnchor { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=QzA4c4QHZCY} /// +/// {@tool dartpad --template=stateful_widget_material} +/// +/// The following example has a [Draggable] widget along with a [DragTarget] +/// in a row demonstrating an incremented `acceptedData` integer value when +/// you drag the element to the target. +/// +/// ```dart +/// int acceptedData = 0; +/// Widget build(BuildContext context) { +/// return Row( +/// mainAxisAlignment: MainAxisAlignment.spaceEvenly, +/// children: [ +/// Draggable( +/// // Data is the value this Draggable stores. +/// data: 10, +/// child: Container( +/// height: 100.0, +/// width: 100.0, +/// color: Colors.lightGreenAccent, +/// child: Center( +/// child: Text("Draggable"), +/// ), +/// ), +/// feedback: Container( +/// color: Colors.deepOrange, +/// height: 100, +/// width: 100, +/// child: Icon(Icons.directions_run), +/// ), +/// childWhenDragging: Container( +/// height: 100.0, +/// width: 100.0, +/// color: Colors.pinkAccent, +/// child: Center( +/// child: Text("Child When Dragging"), +/// ), +/// ), +/// ), +/// DragTarget( +/// builder: ( +/// BuildContext context, +/// List accepted, +/// List rejected, +/// ) { +/// return Container( +/// height: 100.0, +/// width: 100.0, +/// color: Colors.cyan, +/// child: Center( +/// child: Text("Value is updated to: $acceptedData"), +/// ), +/// ); +/// }, +/// onAccept: (int data) { +/// setState(() { +/// acceptedData += data; +/// }); +/// }, +/// ), +/// ], +/// ); +/// } +/// +/// ``` +/// +/// {@end-tool} +/// /// See also: /// /// * [DragTarget]