dart_either 2.1.0 copy "dart_either: ^2.1.0" to clipboard
dart_either: ^2.1.0 copied to clipboard

Either monad for Dart language and Flutter framework. Type-safe error handling, railway oriented programming. Supports Monad comprehensions, async map, async flatMap.

2.1.0 Mar 07, 2026 #

  • Promoted Either.parSequenceN and Either.parTraverseN from experimental to stable.
  • Added complete API docs and examples for Either.parSequenceN and Either.parTraverseN.
  • Added unit tests for Either.parSequenceN and Either.parTraverseN, including concurrency-limit and short-circuit cases.
  • Added @useResult annotations to public APIs that should not be ignored (for example: isLeft, isRight, map, flatMap, swap, exists, all, toEitherStream, left, right, and others).

API migration notes #

  • Either.parSequenceN changed from positional parameters to named parameters:
    // Before (2.0.0)
    Either.parSequenceN<String, int>(functions, n);
    
    // Now (2.1.0)
    Either.parSequenceN<String, int>(
      functions: functions,
      maxConcurrent: n,
    );
    
  • Either.parTraverseN changed from positional parameters to named parameters:
    // Before (2.0.0)
    Either.parTraverseN<String, int, int>(values, mapper, n);
    
    // Now (2.1.0)
    Either.parTraverseN<String, int, int>(
      values: values,
      mapper: mapper,
      maxConcurrent: n,
    );
    
  • maxConcurrent controls concurrency.
    • Pass a number (for example 2) to limit concurrency.
    • Pass null for unlimited concurrency.

2.0.0 Sep 01, 2024 #

  • Require Dart 3.0.0 or higher >=3.0.0 <4.0.0.

  • Make Either a sealed class, EitherEffect a sealed class, and ControlError a final class. Now you can use exhaustive switch expressions on Either instances.

    final Either<String, int> either = Either.right(10);
      
    // Use the `when` method to handle
    either.when(
      ifLeft: (l) => print('Left: $l'),
      ifRight: (r) => print('Right: $r'),
    ); // Prints Right: Either.Right(10)
      
    // Or use Dart 3.0 switch expression syntax 🤘
    print(
      switch (either) {
        Left() => 'Left: $either',
        Right() => 'Right: $either',
      },
    ); // Prints Right: Either.Right(10)
    

1.0.0 Aug 23, 2022 #

  • This is our first stable release.

0.0.1 Apr 27, 2021 #

  • Initial version, created by Stagehand
21
likes
150
points
25.1k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Either monad for Dart language and Flutter framework. Type-safe error handling, railway oriented programming. Supports Monad comprehensions, async map, async flatMap.

Repository (GitHub)
View/report issues

Topics

#hoc081098 #functional-programming #fpdart #dartz #either

Funding

Consider supporting this project:

www.buymeacoffee.com

License

MIT (license)

Dependencies

built_collection, meta

More

Packages that depend on dart_either