StateValidator class

Validates that state data is JSON-serializable and safe for checkpoint.

This validator ensures that state data conforms to the checkpoint requirements:

  • Must be JSON-serializable (Map, List, primitives)
  • Must not contain non-serializable types (BuildContext, Streams, etc.)

Restrictions:

  • ❌ No BuildContext or widget references
  • ❌ No Streams, Controllers, Futures, or async handles
  • ❌ No platform handles (File, Socket, etc.)
  • ❌ No closures or functions
  • ❌ No circular references
  • ✅ Only JSON-serializable types: Map, List, String, num, bool, null

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 Methods

validate(dynamic value, [String path = 'root']) bool
Validates that a value is JSON-serializable and safe for checkpoint.
validateAndSerialize(dynamic value, [String? key]) String
Validates and attempts to serialize a value to JSON.