mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Update Draggable API Docs (#69527)
This commit is contained in:
parent
50970cd777
commit
ee5c080d7b
|
@ -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<int>(
|
||||
/// // 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<dynamic> accepted,
|
||||
/// List<dynamic> 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]
|
||||
|
|
Loading…
Reference in a new issue