StateSnapshot class

Main entry point for the Checkpoint SDK.

This class provides static methods for enabling checkpoint functionality, registering state contributors, capturing snapshots, and restoring state.

Important: This package is dev-only and must be enabled using:

assert(() {
  StateSnapshot.enable();
  return true;
}());

This ensures zero overhead in release builds.

State Safety:

All state data must be JSON-serializable. The SDK automatically validates exported state during capture and will throw StateError if non-serializable types are detected. See register documentation for detailed restrictions.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

isEnabled bool
Returns whether checkpoint is currently enabled.
no setter
onAfterRestore List<void Function()>
List of callbacks to be invoked after restore completes.
final
onBeforeRestore List<void Function()>
List of callbacks to be invoked before restore starts.
final

Static Methods

capture({String? appVersion, Map<String, dynamic>? metadata, List<String>? keys}) Future<Snapshot>
Captures a snapshot of the current application state.
disable() → void
Disables checkpoint functionality.
enable() → void
Enables checkpoint functionality.
ensureEnabled() → void
Ensures checkpoint is enabled, throwing if it's not.
register<T>({required String key, required Map<String, dynamic> exporter(), required void importer(Map<String, dynamic>)}) → void
Registers a state contributor with the checkpoint system.
restoreFromJson(String jsonString, {List<String>? keys, bool continueOnError = false}) Future<void>
Restores application state from a JSON string.
restoreFromJsonMap(Map<String, dynamic> json, {List<String>? keys, bool continueOnError = false}) Future<void>
Restores application state from a JSON map.
unregister(String key) bool
Unregisters a state contributor.
validateSnapshot(String jsonString) Future<SnapshotValidationResult>
Validates a snapshot before restoring it.