either_dart
1.0.0, released 3 years ago by an unverified publisher
Type‑safe Either monad for handling errors without exceptions in Dart/Flutter.
WASM-ready
What it does
Provides Left/Right containers to represent failures and successes, with synchronous and asynchronous transformation methods. Includes extensions for Future<Either> to simplify async error handling.
AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need functional‑style error handling instead of try/catch
- You want to chain async operations while propagating errors
- You prefer explicit success/failure types over nullable values
Skip it when
- You require a full state‑management solution
- You need built‑in networking or JSON serialization
Strengths
- Clear separation of error and success paths
- Supports both sync and async pipelines
- No external dependencies
Weaknesses
- Adds boilerplate of wrapping values in Either
- Limited to error handling; not a full framework
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
Either<MyError, String> getCityNameByCode(int code) {
const cities = <int, String>{/*...*/};
return cities.containsKey(code)
? Right(cities[code]!)
: Left(MyError(key: AppError.NotFound, message: 'Not found'));
}Alternatives
Packages that do the same job and could replace either_dart.