Functional Architecture
Encapsulate Success data and Failures into explicit types. Avoid runtime crashes caused by unhandled implicit exceptions.
Clean Architecture Ready
Designed specifically to protect Use Cases and Repositories. Safely catch Data Layer issues and bubble them up cleanly to your BLoC/Cubit.
Zero Dependencies
Ultra lightweight, performant, and completely dependency-free. Blends seamlessly into any standard Dart or Flutter codebase.
Installation
Add Resultex to your Flutter project with a single command:
$
flutter pub add resultex
How It Works
Replace error-prone try-catch blocks with clear, declarative code flow control.
example_repository.dart
// 1. Define a function that explicitly promises a Success or Failure Result<User, Failure> getUserProfile(String userId) { try { final user = api.fetchUser(userId); return Result.success(user); } catch (exception) { return Result.failure(ServerFailure(exception.toString())); } } void main() { // 2. Execute and process the returned state securely final result = getUserProfile("user_99"); // Flow-control using smooth fold pattern matching result.fold( onSuccess: (user) => print("Success: Active user is ${user.name}"), onFailure: (failure) => print("Error encountered: ${failure.message}"), ); }