Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when recreating NodeEditor widget with the same controller #9

Open
ipr-fredrik2 opened this issue Nov 20, 2024 · 0 comments
Open

Comments

@ipr-fredrik2
Copy link

I have a page in my application that builds a NodeEditor, but I retain the controller for it in a global state.

If I rebuild the NodeEditor (the second time) with the previously used controller (that has a bunch of nodes and connections), I get a crash in render_info.dart:16:

/// get the position of object in the screen, correcting by the position of
/// vertical and horizontal scroll
Offset getObjectPosition(NodeEditorController controller, GlobalKey key) {
  var obj = key.currentContext?.findRenderObject();
  final RenderBox stackRenderBox = obj as RenderBox; /// <-- obj IS NULL HERE!

  // fix position by scroll position
  return stackRenderBox.localToGlobal(Offset.zero) -
      controller.stackPos! +
      Offset(controller.horizontalScrollController.offset,
          controller.verticalScrollController.offset);
}

Seems like its due to the global key being recreated when the pins are being recreated (in _InPortWidgetState, when you call controller.addInPort).

Is this a bug, or am I using the library wrong? It works phenomenally otherwise, thank you for creating another fantastic flutter package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant