NetworkResult<T> class
sealed
Generic Wrapper class for handling network results.
- If successful, returns a NetworkSuccess.
- If failed, returns a NetworkError with a NetworkException.
- Implementers
Constructors
- NetworkResult.error(NetworkException error)
-
constfactory
- NetworkResult.success(T data)
-
constfactory
Properties
- data → T?
-
Retrieves the success data if available, otherwise
null.no setter - error → NetworkException?
-
Retrieves the error if the request failed, otherwise
null.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isError → bool
-
Checks if the network response contains an error.
no setter
- isSuccess → bool
-
Checks if the network response is successful.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
map<
S> ({required S success(NetworkSuccess< T> data), required S error(NetworkError<T> error)}) → S - Transforms the network result into a desired type.
-
mapAsync<
S> ({required Future< S> success(NetworkSuccess<T> data), required Future<S> error(NetworkError<T> error)}) → Future<S> - Transforms the network result asynchronously into a desired type.
-
mapAsyncInIsolate<
S> ({required Mapper< T, S> success, required Mapper<NetworkException, S> error, bool useWorkManager = true}) → Future<S> - Maps the network request whether it's success or error to your desired model asynchronously in an isolate.
-
mapDataAsync<
S> ({required Mapper< T, NetworkResult< mapper}) → FutureOr<S> >NetworkResult< S> > - Maps the success case to another type asynchronously, preserving the error case.
-
mapDataAsyncInIsolate<
S> ({required Mapper< T, NetworkResult< mapper, String? exceptionMessage, bool useWorkManager = true}) → Future<S> >NetworkResult< S> > - Maps the network request whether it's success or error to your desired model asynchronously in an isolate.
-
mapDataAsyncOrNull<
S> ({required Mapper< T, S> mapper, Mapper<NetworkException, S> ? errorMapper}) → FutureOr<S?> - Maps the success data to another type asynchronously, With option to map the error case or return null.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
when(
{required void success(T success), required void error(NetworkException error)}) → NetworkResult< T> - Performs an action based on whether the network call was successful or not.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited