CausalEvent class

A single node in the CausalGraph.

Every event has a unique id and an optional parentId linking it to the event that caused it. Together these form a directed acyclic graph (DAG) where edges represent causal relationships.

The parentId is automatically set from CausalityZone.currentContext() at emit time — developers rarely need to set it manually.

Constructors

CausalEvent({String? id, String? parentId, required CausalEventType type, required String description, DateTime? timestamp, Map<String, dynamic>? metadata, Duration? duration})
CausalEvent.fromJson(Map<String, dynamic> json)
Deserializes from JSON. Throws ArgumentError if type field has an invalid enum name.
factory

Properties

description String
Human-readable description: "user_tapped_login", "POST /api/cart", etc.
final
duration Duration?
For async spans (e.g. network requests), the wall-clock duration.
final
hashCode int
The hash code for this object.
no setteroverride
id String
Unique identifier (UUID v4). Auto-generated if not provided.
final
metadata Map<String, dynamic>
Arbitrary key-value metadata (error_type, http_status, widget_type, etc.).
final
parentId String?
The ID of the event that caused this one. Null for root events (e.g. user taps).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timestamp DateTime
When this event occurred.
final
type CausalEventType
What kind of event this is. Determines color coding in DevTools.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes to JSON for DevTools transport, bug reports, and snapshot storage.
toString() String
A string representation of this object.
override

Operators

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