-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
Milestone
Description
// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/widgets.dart';
Future main() async {
runApp(
new Overlay(
initialEntries: [
new OverlayEntry(
builder: (BuildContext context) => new Foo(),
),
],
),
);
}
class Foo extends StatefulWidget {
@override
FooState createState() => new FooState();
}
class FooState extends State<Foo> {
bool _includeDraggable = true;
@override
Widget build(BuildContext context) {
Widget target = new Container(
width: 100.0,
height: 100.0,
decoration: new BoxDecoration(
backgroundColor: new Color(0xFF00FFFF),
),
);
Widget draggable = new Container(
width: 100.0,
height: 100.0,
decoration: new BoxDecoration(
backgroundColor: new Color(0xFFFFFF00),
),
);
List<Widget> stackChildren = [
_includeDraggable
? new Draggable<int>(
data: 1,
dragAnchor: DragAnchor.pointer,
maxSimultaneousDrags: 1,
childWhenDragging: draggable,
feedback: draggable,
child: draggable,
)
: draggable,
new DragTarget<int>(
onWillAccept: (int data) {
setState(() {
_includeDraggable = false;
});
return true;
},
onAccept: (int data) {},
builder: (
BuildContext context,
List<int> candidateData,
List<dynamic> rejectedData,
) =>
target,
),
];
return new Row(
children: stackChildren,
);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels