removeNodeWhere method
removeNodeWhere
Removes all nodes that satisfy the given condition.
Implementation
void removeNodeWhere(bool Function(NodeModel) test) {
List<String> deletedNodes = [];
final finalNodes = data.nodes.where((e) {
final res = !test(e);
if (!res) {
deletedNodes.add(e.id);
}
return res;
}).toList();
_notifier.value = data.copyWith(
nodes: finalNodes,
connections: connections
.where(
(e) =>
!deletedNodes.contains(e.source.nodeId) &&
!deletedNodes.contains(e.target.nodeId),
)
.toList(),
);
}