Session class
A single unit of session state: a type (preset name), a unique id, a caller-chosen key inside its scope, and a schema-free payload.
The payload is a plain Map<String, dynamic> so any session domain —
tokens, cookies, browser state, app-specific blobs — can be held without
a predefined schema (spec FR-001). Domain layers (e.g. the standalone
zikzak_session package, published on pub.dev as v0.2.0) map their
typed structures onto the payload and keep the core generic.
Constructors
-
Session({required String type, required String id, required String key, required Map<
String, dynamic> payload, required SessionMetadata metadata}) -
const
-
Session.fromJson(Map<
String, dynamic> json) -
Rebuilds a session from its portable JSON form.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
Unique session id (stable across serialization round-trips).
final
- key → String
-
Caller-chosen key identifying this session within
(scope, type).final - metadata → SessionMetadata
-
Creation/update/expiry bookkeeping.
final
-
payload
→ Map<
String, dynamic> -
Schema-free session data.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → String
-
The preset/type identifier (e.g.
authToken,browser).final
Methods
-
copyWith(
{Map< String, dynamic> ? payload, int? updatedAt, int? expiresAt}) → Session -
encode(
) → String - Convenience: encode to a JSON string for transport.
-
isExpired(
{int? at}) → bool -
True when the session's expiry has passed as of
at(epoch ms). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Portable single-session JSON. Round-trips through fromJson with full fidelity (type, id, key, payload, metadata) so a session serialized in one runtime deserializes identically in another (spec FR-006/SC-003).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override