applyToGraph method
Apply these global dependencies to the graph for the given node.
Creates granular dependency nodes as needed and adds all relevant dependency edges.
Implementation
void applyToGraph(ProjectGraph graph, String nodeId) {
if (usesTheme) {
graph.addDependency(nodeId, GlobalNodeIds.kThemeNodeId);
}
// Link to granular dependency nodes
for (final (keys, createNodeId, type) in _granularDependencies()) {
_linkToGranularNodes(graph, nodeId, keys, createNodeId, type);
}
// Link to navigation targets and sheet/dialog components
_linkToWidgetClassNodes(graph, nodeId, navigationTargetPageKeys);
_linkToWidgetClassNodes(graph, nodeId, sheetDialogComponentKeys);
// Link to data struct field nodes
for (final entry in dataStructFieldAccesses.entries) {
final structKey = entry.key;
for (final fieldKey in entry.value) {
final targetNodeId = NodeIds.dataStructField(structKey, fieldKey);
if (!graph.hasNode(targetNodeId)) {
graph.addNode(
DependencyNode(
id: targetNodeId,
type: DependencyNodeType.dataStructField,
),
);
}
graph.addDependency(nodeId, targetNodeId);
}
}
// Link to action block param nodes
for (final entry in actionBlockParamPasses.entries) {
final actionBlockKey = entry.key;
for (final paramKey in entry.value) {
final targetNodeId = NodeIds.actionBlockParam(actionBlockKey, paramKey);
if (!graph.hasNode(targetNodeId)) {
graph.addNode(
DependencyNode(
id: targetNodeId,
type: DependencyNodeType.actionBlockParam,
),
);
}
graph.addDependency(nodeId, targetNodeId);
}
}
// Link to library dependency nodes
for (final projectId in allLibraryProjectIds) {
final targetNodeId = NodeIds.libraryDependency(projectId);
if (!graph.hasNode(targetNodeId)) {
graph.addNode(
DependencyNode(
id: targetNodeId,
type: DependencyNodeType.libraryDependency,
),
);
}
graph.addDependency(nodeId, targetNodeId);
}
}