rewind method

Implementation

EntityGraphDevtoolsRewindResult? rewind(int cursor) {
  if (!timeTravelEnabled || isDisposed || _previewReceipts.isNotEmpty) {
    return null;
  }
  final retained = _retainedSnapshots
      .where((snapshot) => snapshot.reference.cursor == cursor)
      .firstOrNull;
  if (retained == null) return _expiredSnapshotReceipt(this, cursor);
  final transition = _enterRewind(
    this,
    cursor: cursor,
    source: EntityGraphDevtoolsSnapshotSource.retained,
    target: retained.data,
  );
  if (transition == null) return null;
  _projectionFailureRevision += 1;
  final event = _publishTimeTravel(
    state: EntityGraphDevtoolsHistoryMode.rewound,
    cursor: cursor,
    previousCursor: transition.previousCursor,
    source: EntityGraphDevtoolsSnapshotSource.retained,
    previousSource: transition.previousSource,
    reason: EntityGraphDevtoolsTimeTravelReason.command,
  );
  return EntityGraphDevtoolsRewindReceipt(
    cursor: cursor,
    previousCursor: transition.previousCursor,
    previousSource: transition.previousSource,
    changedAt: event.observedAt,
  );
}