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
420 stars 114 forks source link

mouse_tracker.dart error and complete freeze #45

Closed DirtyNative closed 2 years ago

DirtyNative commented 3 years ago

I am using the graph view inside one of my views and struggle getting it to work without freezing. I get a massive load of errors while the mouse is over the graph:

════════ Exception caught by scheduler library ═════════════════════════════════
'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 201 pos 12: '!_debugDuringDeviceUpdate': is not true.
════════════════════════════════════════════════════════════════════════════════
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: 'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 201 pos 12: '!_debugDuringDeviceUpdate': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2      MouseTracker._deviceUpdatePhase
package:flutter/…/rendering/mouse_tracker.dart:201
#3      MouseTracker.updateWithEvent.<anonymous closure>
package:flutter/…/rendering/mouse_tracker.dart:309
#4      MouseTracker._monitorMouseConnection
package:flutter/…/rendering/mouse_tracker.dart:190

My code for the view:

@override
  Widget build(BuildContext context) {
    return ViewModelBuilder<TechTreeViewModel>.reactive(
      builder: (context, model, snapshot) => ScaffoldBase(
        body: 

// I just tried to see if this is caused by unbound sizes... its not
SizedBox(
          height: 400,
          width: 400,
          child: InteractiveViewer(
            constrained: false,
            scaleEnabled: false,
            maxScale: 1,
            minScale: 1,
            boundaryMargin: EdgeInsets.all(100),
            child: GraphView(
              algorithm: BuchheimWalkerAlgorithm(
                model.builder,
                TreeEdgeRenderer(model.builder),
              ),
              graph: model.graph,
              paint: Paint()
                ..color = Colors.green
                ..strokeWidth = 1
                ..style = PaintingStyle.stroke,
              builder: (Node node) {
                if (node.key.value is TechTreeConditionNode) {
                  return conditionNode(node.key.value);
                } else if (node.key.value is TechTreeTechnologyNode) {
                  return rootNode(node.key.value);
                }

                return Container(
                  width: 100,
                  height: 100,
                );
              },
            ),
          ),
        ),
      ),
    );
  }

  Widget rootNode(TechTreeTechnologyNode nodeModel) {
    return InkWell(
      child: Container(
        height: 100,
        width: 200,
        padding: EdgeInsets.all(16),
        child: Column(
          children: [
            Text(nodeModel.technology.name),
          ],
        ),
      ),
    );
  }

And inside my ViewModel:

  Graph graph;
  BuchheimWalkerConfiguration builder;

  TechTreeViewModel( ) {
    graph = Graph()..isTree = true;
    builder = new BuchheimWalkerConfiguration();
  }

I tried to find out, what is causing this issue, but haven't found anything. If you need more info, please let me know

nabil6391 commented 3 years ago

The error happens for any algorithm ?

DirtyNative commented 3 years ago

Happens also with SugiyamaAlgorithm

nabil6391 commented 2 years ago

Can you try wrapping the text with Center widget

Try updating the flutter channel

nabil6391 commented 2 years ago

Is this still relevant? otherwise I will close this