processItem method Null safety
- PipelineFlowItem? item
Process PipelineFlowItem along pipeline
Implementation
processItem(PipelineFlowItem? item) async {
String? next = start;
// Process each connection
for (var connection in connections) {
String? step = processes.nameFor(connection.source);
// check if the steps are connected
if (step != null && step == next) {
final operation = registry.operationFor(step);
if (operation != null && item != null) {
item = await operation.process(item);
if (item == null) break;
}
next = processes.nameFor(connection.target);
} else {
throw Exception(
'Pipeline Exception: Next step ($next) does not match '
'the current step ($step)',
);
}
}
/// Emit result only if pipeline completed with a non-null item with data
if (item != null) {
result(item);
}
}