-
-
Notifications
You must be signed in to change notification settings - Fork 140
Description
- Simulating on an iPhone 16e
- iOS 26.1
Hey there! I ran into this library and was trying to use it to create a graph connecting disparate ideas. I wanted to try this with the FruchtermanReingoldAlgorithm.
So far I've found two ways to just create this graph. One is via the InteractiveView method, outlined in the examples:
Expanded(
child: InteractiveViewer(
constrained: false,
boundaryMargin: EdgeInsets.all(8),
minScale: 0.001,
maxScale: 10000,
child: GraphViewCustomPainter(
graph: graph,
algorithm: algorithm,
paint: Paint()
..color = Colors.green
..strokeWidth = 1
..style = PaintingStyle.fill,
builder: (Node node) {
// I can decide what widget should be shown here based on the id
var a = node.key!.value as int?;
if (a == 2) {
return rectangWidget(a);
}
return rectangWidget(a);
})),
),
As-is this creates a graph that animates. The nodes eventually settle into a reasonable position, and they are also draggable. The screen itself is not, but this allows the user to bypass any annoying overlapping problems.
On the other hand, we have the graphview builder method. After consulting the docs, mine currently looks like this:
Expanded(
child: GraphView.builder(
graph: graph,
animated: true,
algorithm: algorithm,
controller: controller,
panAnimationDuration: Duration(milliseconds: 600),
toggleAnimationDuration: Duration(milliseconds: 400),
initialNode: ValueKey(1),
builder: (Node node) {
var a = node.key!.value.toString() as String;
return rectangleWidget(a);
},
),
),
The issue here is that I currently cannot drag anything with the graph, move nodes around, etc and it isn't entirely clear why. I have experimented with multiple variations of this code, but nothing allows me to control the drag of the individual nodes, (or even let the builder animate properly), is there something I need to override or something that isn't mentioned in the docs?
Happy to fill in any missing details - thanks!