GraphView: Show the Node's label

This commit is contained in:
Vishesh Handa
2020-08-18 13:37:57 +02:00
parent f2dcc4d193
commit 7c1eade09b

View File

@ -502,7 +502,7 @@ class _GraphStackViewState extends State<GraphStackView> {
for (var node in widget.graph.nodes) { for (var node in widget.graph.nodes) {
var w = Positioned( var w = Positioned(
child: GestureDetector( child: GestureDetector(
child: NodeWidget(), child: NodeWidget(node),
onPanStart: (details) { onPanStart: (details) {
node.x = details.globalPosition.dx; node.x = details.globalPosition.dx;
node.y = details.globalPosition.dy; node.y = details.globalPosition.dy;
@ -538,15 +538,25 @@ class _GraphStackViewState extends State<GraphStackView> {
} }
class NodeWidget extends StatelessWidget { class NodeWidget extends StatelessWidget {
final Node node;
NodeWidget(this.node);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Column(
width: 50, children: [
height: 50, Container(
decoration: const BoxDecoration( width: 50,
color: Colors.orange, height: 50,
shape: BoxShape.circle, decoration: const BoxDecoration(
), color: Colors.orange,
shape: BoxShape.circle,
),
),
Text(node.label),
],
crossAxisAlignment: CrossAxisAlignment.center,
); );
} }
} }