switchTo method
Activates the flow id and pauses the rest. Only one "main" flow receives intents.
Why use it: After login you want only AuthFlow (or HomeFlow) to be active.
Example: flowManager.switchTo("authFlow"); on startup. Idempotent.
Implementation
bool switchTo(String id) {
final target = _flows[id];
if (target == null) return false;
final alreadyOnlyRunning =
target.state == OmegaFlowState.running &&
_flows.values.every((f) =>
f.id == id || f.state != OmegaFlowState.running);
if (alreadyOnlyRunning) {
activeFlowId = id;
return true;
}
for (final flow in _flows.values) {
if (flow.id == id) {
flow.start();
activeFlowId = id;
} else if (flow.state == OmegaFlowState.running) {
flow.pause();
}
}
return true;
}