setTheme method
Set the theme and update the connection painter.
This is called internally by the editor widget only.
Parameters:
theme: The theme to apply to the graph editor
Implementation
void setTheme(NodeFlowTheme theme) {
final isFirstTimeSetup = _connectionPainter == null;
// Create painter if it doesn't exist, otherwise update its theme
if (isFirstTimeSetup) {
_connectionPainter = ConnectionPainter(
theme: theme,
// Cast to Node<dynamic> since ConnectionPainter is not generic
nodeShape: _nodeShapeBuilder != null
? (node) => _nodeShapeBuilder!(node as Node<T>)
: null,
);
} else {
_connectionPainter!.updateTheme(theme);
}
// Update observable theme - this triggers the reaction for spatial index rebuild
runInAction(() => _themeObservable.value = theme);
// If this is the first time setup and we have pre-loaded nodes from
// the constructor, set up the infrastructure now that we have a theme
if (isFirstTimeSetup && _nodes.isNotEmpty) {
_setupLoadedGraphInfrastructure();
}
}