From 7c1eade09b20624b5ce2edd62fd3748e4c270a7f Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 18 Aug 2020 13:37:57 +0200 Subject: [PATCH] GraphView: Show the Node's label --- lib/main_graph.dart | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/main_graph.dart b/lib/main_graph.dart index 93a257f5..bc2f5b29 100644 --- a/lib/main_graph.dart +++ b/lib/main_graph.dart @@ -502,7 +502,7 @@ class _GraphStackViewState extends State { for (var node in widget.graph.nodes) { var w = Positioned( child: GestureDetector( - child: NodeWidget(), + child: NodeWidget(node), onPanStart: (details) { node.x = details.globalPosition.dx; node.y = details.globalPosition.dy; @@ -538,15 +538,25 @@ class _GraphStackViewState extends State { } class NodeWidget extends StatelessWidget { + final Node node; + + NodeWidget(this.node); + @override Widget build(BuildContext context) { - return Container( - width: 50, - height: 50, - decoration: const BoxDecoration( - color: Colors.orange, - shape: BoxShape.circle, - ), + return Column( + children: [ + Container( + width: 50, + height: 50, + decoration: const BoxDecoration( + color: Colors.orange, + shape: BoxShape.circle, + ), + ), + Text(node.label), + ], + crossAxisAlignment: CrossAxisAlignment.center, ); } }