ApiExecutor class

Executes an asynchronous operation safely and wraps the result in a Result without throwing exceptions to the caller.

Intended to be used in data sources or repositories.

Constructors

ApiExecutor()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Static Methods

execute<T>({required Future<T> apiCall(), bool isTokenExpired(T response)?, String unexpectedErrorMessage = 'Unexpected error', String sessionExpiredMessage = 'Session expired'}) Future<Result<T>>
Executes apiCall and returns a Success or Failure.