Skip to content

Commit 0cb314b

Browse files
authored
Merge pull request #115 from emmby/master
Update GraphView.dart
2 parents 76ddad3 + 52b8d8c commit 0cb314b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/GraphView.dart

+3-6
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,11 @@ class _GraphViewAnimated extends StatefulWidget {
239239
final Graph graph;
240240
final Algorithm algorithm;
241241
final Paint? paint;
242-
final nodes = <Widget>[];
242+
final NodeWidgetBuilder builder;
243243
final stepMilis = 25;
244244

245245
_GraphViewAnimated(
246-
{Key? key, required this.graph, required this.algorithm, this.paint, required NodeWidgetBuilder builder}) {
247-
graph.nodes.forEach((node) {
248-
nodes.add(node.data ?? builder(node));
249-
});
246+
{Key? key, required this.graph, required this.algorithm, this.paint, required this.builder}) {
250247
}
251248

252249
@override
@@ -296,7 +293,7 @@ class _GraphViewAnimatedState extends State<_GraphViewAnimated> {
296293
...List<Widget>.generate(graph.nodeCount(), (index) {
297294
return Positioned(
298295
child: GestureDetector(
299-
child: widget.nodes[index],
296+
child: graph.nodes[index].data ?? widget.builder(graph.nodes[index]),
300297
onPanUpdate: (details) {
301298
graph.getNodeAtPosition(index).position += details.delta;
302299
update();

0 commit comments

Comments
 (0)