ChatResult<T> class sealed

Represents the outcome of an SDK operation: either ChatSuccess with data or ChatFailureResult with a ChatFailure.

Use fold to handle both cases, or check isSuccess/isFailure and access dataOrNull/failureOrNull directly.

Implementers

Properties

dataOrNull → T?
no setter
dataOrThrow → T
Returns the wrapped data, throwing StateError when this is a ChatFailureResult. Use only when the caller has already verified isSuccess (when/if-case) and wants the unwrap to be a programmer error if it isn't. Prefer fold / getOrElse in normal code.
no setter
failureOrNull ChatFailure?
no setter
failureOrThrow ChatFailure
Returns the wrapped failure, throwing StateError when this is a ChatSuccess. Symmetric to dataOrThrow. Use after an isFailure check when you need the failure for typed propagation; prefer castFailure when the goal is just to rewrap the failure with a different success type.
no setter
hashCode int
The hash code for this object.
no setterinherited
isFailure bool
no setter
isSuccess bool
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

castFailure<R>() ChatResult<R>
Re-wraps a ChatFailureResult under a new success type R. Throws StateError when this is a ChatSuccess. Replaces the common idiom ChatFailureResult<R>(result.failureOrNull!) after an isFailure check.
flatMap<R>(Future<ChatResult<R>> transform(T data)) Future<ChatResult<R>>
fold<R>(R onFailure(ChatFailure failure), R onSuccess(T data)) → R
getOrElse(T fallback) → T
Returns the wrapped data, or fallback when this is a ChatFailureResult. Convenience for result.fold((_) => fallback, (d) => d) when the caller just wants a sane default and doesn't care about the failure shape.
getOrElseLazy(T onFailure(ChatFailure failure)) → T
Returns the wrapped data, or computes one from the failure. Use when the fallback depends on what went wrong (e.g. partial cache after a network error).
map<R>(R transform(T data)) ChatResult<R>
mapFailure(ChatFailure transform(ChatFailure failure)) ChatResult<T>
Transforms the failure side of a ChatResult without touching the success side. Useful for wrapping a low-level ChatFailure in a domain-specific one before propagating.
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