alexst07 / flutter_node_editor

Package for creating visual programming interfaces inspired by Blender Nodes and Unreal Engine Blueprints. https://pub.dev/packages/node_editor
BSD 3-Clause "New" or "Revised" License
28 stars 7 forks source link

Resolved Null subtype error of RenderBox #2

Closed ShaSam2104 closed 3 months ago

ShaSam2104 commented 3 months ago

1 This PR modifies the getNodeWidgetSize function to ensure that the RenderBox of the NodeEditor widget is properly laid out and rendered before attempting to access its size. The function first checks if the NodeModel and its associated GlobalKey exist. If the GlobalKey is not null, the code that retrieves the RenderBox is deferred until after the current frame has been rendered using WidgetsBinding.instance.addPostFrameCallback. Inside the callback function, the RenderBox is retrieved from the GlobalKey, and its size is assigned to the size variable. If the RenderBox is null, the size variable is set to Size.zero. By deferring the execution of the code that accesses the RenderBox until after the current frame has been rendered, the function ensures that the NodeEditor widget has been properly laid out, resolving the type 'Null' is not a subtype of type 'RenderBox' error.