Result<T, E> class
sealed
Encapsulates either a result (value of generic type T) or an error (value of generic type E).
- Implementers
- Available extensions
Properties
- errorOrNull → E?
-
Available on Result<
Returns the error if it exists, otherwise nullT, E> , provided by the NullResultExtensions extensionno setter - firstOrNull → T?
-
Available on ListResult<
Returns the list if it is success null otherwiseT, E> , provided by the ListResultExtensions extensionno setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Available on IterableResult<
Returns true if the result is not successful or the list is empty.T, E> , provided by the ListResultExtensions extensionno setter - isError → bool
-
Whether or the not the result was an error
no setter
- isNotEmpty → bool
-
Available on IterableResult<
Returns true if this instance represents a success result and there are itemse in the list.T, E> , provided by the ListResultExtensions extensionno setter - isSuccess → bool
-
Whether or not that the result was a success
no setter
- lengthOrNull → int?
-
Available on ListResult<
Returns the length of the list if it is success null otherwiseT, E> , provided by the ListResultExtensions extensionno setter - resultOrNull → T?
-
Available on Result<
Returns the result a the specified valueT, E> , provided by the NullResultExtensions extensionno setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
bind<
U> (Result< U, E> f(T)) → Result<U, E> -
Available on Result<
Performs a bind operation and returns a new instance with a new type. The 'bind' method allows chaining operations that may fail.T, E> , provided by the ResultExtensions extension -
firstWhereOrNull(
bool predicate(T)) → T? -
Available on ListResult<
Returns the first value in the list if it is success null otherwiseT, E> , provided by the ListResultExtensions extension -
iterableOr(
Iterable< T> orElse) → Iterable<T> -
Available on IterableResult<
Returns the result if it is a success, or the result ofT, E> , provided by the ListResultExtensions extensionorElse -
lengthOr(
int length) → int -
Available on IterableResult<
Returns the length of the list if it is a success, orT, E> , provided by the ListResultExtensions extensionlength -
map<
U> (U f(T)) → Result< U, E> -
Available on Result<
The 'map' method transforms the successful value without changing the error.T, E> , provided by the ResultExtensions extension -
mapOrNull<
U> (U transform(T)) → U? -
Available on Result<
Returns a transformed value or nullT, E> , provided by the NullResultExtensions extension -
match<
U> ({required U onSuccess(T), required U onError(E)}) → U -
Available on Result<
Achieves the same thing as a switch expression with pattern matching. You should consider using a switch expression, but sometimes the match function is simplerT, E> , provided by the ResultExtensions extension -
merge<
M, J> (Result< J, E> other, M onJoin(T, J)) → Result<M, E> -
Available on Result<
Performs a merge operation and returns a new instance ofT, E> , provided by the ResultExtensions extensionM. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resultOr(
T or) → T -
Available on Result<
Returns the result a the specified valueT, E> , provided by the ResultExtensions extension -
sorted<
M extends IterableResult< (T, E> >int compare(T a, T b), {required Iterable< T> onSuccess(Iterable<T> )}) → IterableResult<T, E> -
Available on IterableResult<
Performs a sort operation and returns a new instance ofT, E> , provided by the ListResultExtensions extensionM. -
takeOrNull(
int i) → Iterable< T> ? -
Available on ListResult<
Returns the first n elements of the list if it is success or nullT, E> , provided by the ListResultExtensions extension -
toString(
) → String -
A string representation of this object.
inherited
-
where(
bool predicate(T), {required Iterable< T> onError(E)}) → Iterable<T> -
Available on IterableResult<
Performs a filter operation and returns a new instance ofT, E> , provided by the ListResultExtensions extensionT. -
whereOrNull(
bool predicate(T)) → Iterable< T> ? -
Available on ListResult<
Returns the filtered elements of the list if it is success or nullT, E> , provided by the ListResultExtensions extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator >>(
Result< T, E> transform(T)) → Result<T, E> -
Available on Result<
Performs a bind operation and returns a new instance.T, E> , provided by the ResultExtensions extension -
operator |(
T or) → T -
Available on Result<
Returns the success value if it exists, otherwise returnsT, E> , provided by the ResultExtensions extensionor