dartz_plus 0.3.0
dartz_plus: ^0.3.0 copied to clipboard
A functional programming library for Dart and Flutter providing type-safe error handling with Either type, functional composition, and async support.
Changelog #
All notable changes to this project will be documented in this file.
0.3.0 - 2026-01-03 #
- Added
@MapToand@IgnoreMapannotations to support advanced object mapping. - Updated
@Mapperannotation to support specifying a target constructor. - Refactored internal library structure to use
partandpart ofdirectives.
0.2.0 - 2026-01-03 #
- Added new type mapper to support auto mapper with
dartz_plus_generatorpackage.
0.1.0 - 2025-12-06 #
Added #
foldAsync: Asynchronous version offoldthat accepts both synchronous and asynchronous functions.fromNullable: Static method to create anEitherfrom a nullable value.cond: Static method to create anEitherbased on a condition.tryCatch: Static method to execute a function and catch any exceptions as aLeft.filterOrElse: Method to filterRightvalues, converting toLeftif the predicate fails.tap: Method to execute a side effect onRightvalues without changing the result.- Improved
toStringimplementation for better debugging. - comprehensive example application showcasing various features:
- Basic usage
- Async handling
- Error handling
- Functional programming enhancements
- Real-world API integration
- Chaining strategies
0.0.1 2025-12-XX #
Added #
- Initial release of
dartz_plus Either<L, R>sealed class for representing disjoint union typesLeft<L, R>class representing the left side (typically errors/failures)Right<L, R>class representing the right side (typically success values)- Factory constructors:
Either.left(L value)- Creates aLeftinstanceEither.right(R value)- Creates aRightinstance
- Getters:
isLeft- Returnstrueif this is aLeftinstanceisRight- Returnstrueif this is aRightinstanceleftValue- Returns the left value if this is aLeft, otherwisenullrightValue- Returns the right value if this is aRight, otherwisenull
- Core methods:
fold<T>(T Function(L l) left, T Function(R r) right)- Applies the appropriate function based on whether this is aLeftorRightfoldAsync<T>(FutureOr<T> Function(L l) left, FutureOr<T> Function(R r) right)- Async version offoldthat accepts both synchronous and asynchronous functionsswap()- Swaps the left and right types
- Transformation methods:
map<T>(T Function(R r) f)- Transforms theRightvalue using the given functionmapLeft<T>(T Function(L l) f)- Transforms theLeftvalue using the given functionbimap<L2, R2>(L2 Function(L l) left, R2 Function(R r) right)- Transforms bothLeftandRightvalues using the given functions
- Composition methods:
flatMap<T>(Either<L, T> Function(R r) f)- ChainsEitheroperations (monadic bind)getOrElse(R Function() orElse)- Returns the right value if this is aRight, otherwise returns the result of callingorElse(lazy evaluation)orElse(Either<L, R> Function() alternative)- Returns thisEitherif it's aRight, otherwise returns the result of callingalternative(lazy evaluation)
- Equatable support for value equality comparison
- Comprehensive test coverage
- README documentation with usage examples
Dependencies #
equatable: ^2.0.7- For value equalityflutterSDK - Required for Flutter support
Requirements #
- Dart SDK: ^3.10.1
- Flutter SDK