SyncUseCase<T, Params> class
abstract
Base class for synchronous UseCases that return immediately without async.
Use this for operations that don't require asynchronous processing, such as validation, calculations, or data transformations.
Example
class ValidateEmailUseCase extends SyncUseCase<bool, String> {
@override
bool execute(String email) {
return RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(email);
}
}
// Usage
final validateEmail = ValidateEmailUseCase();
final result = validateEmail('user@example.com');
result.fold(
(isValid) => print('Email is valid: $isValid'),
(failure) => print('Validation failed: $failure'),
);
Constructors
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
-
call(
Params params) → Result< T, AppFailure> - Call the UseCase and wrap the result in a Result.
-
execute(
Params params) → T - Execute the UseCase synchronously.
-
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