restoreFromSnapshot method

void restoreFromSnapshot(
  1. OmegaAppSnapshot snapshot
)

Restores each flow's memory and activates the flow that was active. Call when opening the app after loading the snapshot.

Example: final snapshot = OmegaAppSnapshot.fromJson(jsonDecode(loaded)); flowManager.restoreFromSnapshot(snapshot);

Implementation

void restoreFromSnapshot(OmegaAppSnapshot snapshot) {
  for (final flowSnapshot in snapshot.flows) {
    final flow = _flows[flowSnapshot.flowId];
    if (flow != null) {
      flow.restoreMemory(flowSnapshot.memory);
    }
  }
  activeFlowId = snapshot.activeFlowId;
  if (snapshot.activeFlowId != null) {
    switchTo(snapshot.activeFlowId!);
  }
}