dartz_plus 0.3.0 copy "dartz_plus: ^0.3.0" to clipboard
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 @MapTo and @IgnoreMap annotations to support advanced object mapping.
  • Updated @Mapper annotation to support specifying a target constructor.
  • Refactored internal library structure to use part and part of directives.

0.2.0 - 2026-01-03 #

  • Added new type mapper to support auto mapper with dartz_plus_generator package.

0.1.0 - 2025-12-06 #

Added #

  • foldAsync: Asynchronous version of fold that accepts both synchronous and asynchronous functions.
  • fromNullable: Static method to create an Either from a nullable value.
  • cond: Static method to create an Either based on a condition.
  • tryCatch: Static method to execute a function and catch any exceptions as a Left.
  • filterOrElse: Method to filter Right values, converting to Left if the predicate fails.
  • tap: Method to execute a side effect on Right values without changing the result.
  • Improved toString implementation 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 types
  • Left<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 a Left instance
    • Either.right(R value) - Creates a Right instance
  • Getters:
    • isLeft - Returns true if this is a Left instance
    • isRight - Returns true if this is a Right instance
    • leftValue - Returns the left value if this is a Left, otherwise null
    • rightValue - Returns the right value if this is a Right, otherwise null
  • Core methods:
    • fold<T>(T Function(L l) left, T Function(R r) right) - Applies the appropriate function based on whether this is a Left or Right
    • foldAsync<T>(FutureOr<T> Function(L l) left, FutureOr<T> Function(R r) right) - Async version of fold that accepts both synchronous and asynchronous functions
    • swap() - Swaps the left and right types
  • Transformation methods:
    • map<T>(T Function(R r) f) - Transforms the Right value using the given function
    • mapLeft<T>(T Function(L l) f) - Transforms the Left value using the given function
    • bimap<L2, R2>(L2 Function(L l) left, R2 Function(R r) right) - Transforms both Left and Right values using the given functions
  • Composition methods:
    • flatMap<T>(Either<L, T> Function(R r) f) - Chains Either operations (monadic bind)
    • getOrElse(R Function() orElse) - Returns the right value if this is a Right, otherwise returns the result of calling orElse (lazy evaluation)
    • orElse(Either<L, R> Function() alternative) - Returns this Either if it's a Right, otherwise returns the result of calling alternative (lazy evaluation)
  • Equatable support for value equality comparison
  • Comprehensive test coverage
  • README documentation with usage examples

Dependencies #

  • equatable: ^2.0.7 - For value equality
  • flutter SDK - Required for Flutter support

Requirements #

  • Dart SDK: ^3.10.1
  • Flutter SDK
2
likes
150
points
204
downloads

Publisher

unverified uploader

Weekly Downloads

A functional programming library for Dart and Flutter providing type-safe error handling with Either type, functional composition, and async support.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

equatable, meta

More

Packages that depend on dartz_plus