nabil6391 / graphview

Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
MIT License
424 stars 117 forks source link

Graphs Larger Than Container Size Throw Exception #16

Closed cedarbob closed 3 years ago

cedarbob commented 3 years ago

When you try to display a graph whose nominal size is larger than the available display size, an exception gets thrown due to an assertion failure ("A renderflex overflowed by x pixels ..."), and Flutter shows a border with yellow/black diagonal stripes on the offending side. Enlarging the window gets rid of it; shrinking the window gets it back. I haven't found an easy workaround yet.

nabil6391 commented 3 years ago

Remove Expanded widget and try Interactive Viewer Constrained to true

InteractiveViewer( constrained: true, scaleEnabled: false, boundaryMargin: EdgeInsets.all(100), minScale: 0.01, maxScale: 5.6, child: GraphView( graph: graph, algorithm: BuchheimWalkerAlgorithm(builder), )),

cedarbob commented 3 years ago

That doesn't help, as you can see in your graphview_example.dart code (the uploaded screenshot for issue #16 shows the bottom edge overflow I'm referring to in this issue). I have not found a good workaround yet, but will investigate whether setting an initial scale for the InteractiveViewer will help.

holethienthanh commented 3 years ago

Same problem. I just wrap it into Expanded() and change constrained to false. Expanded(child: InteractiveViewer( constrained: false,....

cedarbob commented 3 years ago

Wrapping in a FittedBox also seems to work.