SafeData<T> class
Runtime-managed field for short-lived or sensitive data.
Constructors
- SafeData({T? initialValue, required SafeDataPolicy policy, SafeDataNow? now})
-
Creates a managed field with an optional
initialValue. -
SafeData.memoryOnly({T? initialValue, bool clearOnDispose = true, Duration? expiresAfter, Set<
Object> clearOnCommandSuccess = const <Object>{}, Set<Object> clearOnCommandError = const <Object>{}, SafeDataLogStrategy logStrategy = SafeDataLogStrategy.redacted, SafeDataNow? now}) - Creates a field constrained to runtime memory only.
Properties
- expiresAt → DateTime?
-
Absolute expiration deadline for the current value, if any.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasValue → bool
-
Whether a valid value is available right now.
no setter
- isCleared → bool
-
Whether the field was explicitly cleared.
no setter
- isExpired → bool
-
Whether the field has expired.
no setter
- policy → SafeDataPolicy
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → SafeDataStatus
-
Current externally visible status.
no setter
Methods
-
attachRuntime(
{required void onChanged()}) → void - Registers a callback for runtime-visible internal changes.
-
clear(
{SafeDataClearReason reason = SafeDataClearReason.manual}) → void - Clears the current value.
-
detachRuntime(
) → void - Detaches the current runtime callback, if any.
-
handleCommandCompletion(
{required Object commandKey, required bool succeeded}) → bool - Applies command-linked cleanup rules and reports whether the field changed.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readOrNull(
) → T? - Returns the current value when still valid.
-
requireValid(
) → T - Returns the current value or throws if unavailable.
-
set(
T value) → void - Replaces the current value and resets the expiration window.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited