Skip to main content

verdict 2.2.1 copy "verdict: ^2.2.1" to clipboard
verdict: ^2.2.1 copied to clipboard

A sealed Result type and a structured Failure hierarchy for Dart, so calls return a typed verdict instead of throwing across layer boundaries.

2.2.1 #

  • No change to the public API. lib/src/result.dart and two test files weren't dart format-clean, which cost pana its static-analysis points on 2.2.0; this release is the formatted, full-score equivalent.

2.2.0 #

  • Added Result.collectFailuresIndexed, keying each failure by its position in the batch — for reporting which field or row a failure belongs to.
  • Added Result.zip and Result.zip3, combining two or three independent results into a record, both/all evaluated regardless of order.
  • Added Result.tap, running a side effect on either branch without writing it twice via onOk and onErr.
  • Added Failure.toMap() / Failure.toJson(), a JSON-safe map of a failure's displayable fields for logging or an error response — deliberately excluding cause and stackTrace.
  • Added guardWithRetry, the retrying counterpart to guard, for a flaky call worth a second try before mapping the last error.

2.1.0 #

  • Added Result.collectFailures, the complement to Result.collect: gathers every Failure in a list of results instead of stopping at the first one, for validating a batch where every problem should be shown at once.
  • Added a publish.yml workflow: pushing a vX.Y.Z tag on main verifies the tag matches pubspec.yaml and has a CHANGELOG.md entry, then publishes to pub.dev via OIDC (no stored token).

2.0.0 #

  • No change to the published code. CI moved to the shared reusable workflow in CtrlAltDevelop/ci-workflows: formatting, analyze --fatal-infos, the tests, the example, a changelog entry per version, and a pana score with no points lost — the same gate across every package here.
  • The SDK floor moves to Dart 3.12.0 / Flutter 3.44.0, from Dart 3.0.0 / Flutter 3.10.0. This is the floor every package here is gated on rather than something the code needs — sealed classes and pattern matching are all it uses.
  • Dependency bounds are explicit ranges rather than carets — a floor that resolves on the supported SDK, the next major as the ceiling — so a consumer already on an older version in the same major is not forced to move.
  • The README carries the pub, pub points, CI and licence badges the other packages here carry.

1.1.0 #

Additive only — nothing in 1.0.0 changed shape, so the upgrade is a version bump.

  • Lowered the minimum Dart SDK to >=3.0.0 <4.0.0. 1.0.0 required ^3.13.0, but nothing in the package uses a language feature newer than Dart 3.0's sealed classes and pattern matching, so the bound was far stricter than the code needed. Widening it is not breaking: every 1.0.0 consumer still resolves.

  • Floated the dependency bounds — equatable: '>=2.0.0 <3.0.0' — so upgrading verdict no longer forces the rest of a resolution forward.

  • Result gained mapFailure, recover, recoverWith, getOrElseWith, valueOrThrow, the onOk / onErr side-effect taps, the mapAsync / flatMapAsync async counterparts, and the Result.ok / Result.err constructors.

  • Result.collect turns an Iterable<Result<T>> into a Result<List<T>>, short-circuiting on the first failure.

  • flatten() collapses a nested Result<Result<T>>.

  • A FutureResult extension mirrors the whole surface on Future<Result<T>>, so an async pipeline chains forwards instead of nesting awaits.

  • FailureException carries a Failure across a throwing boundary; it is what valueOrThrow throws.

  • Failure gained optional cause and stackTrace diagnostics, and every variant gained copyWith. Both new fields are excluded from equality, so failures compare the same whether or not the original error was kept.

  • DefaultFailureMapper now records the error and its trace as cause and stackTrace.

  • The mapper argument of guard / guardSync is now optional and defaults to DefaultFailureMapper.

1.0.0 #

First stable release. The API is unchanged from 0.1.0 and is now covered by semantic versioning: no breaking change to Result, Failure, the mappers, guard or failureOrigin will land outside a 2.0.0.

  • Breaking: raised the minimum Dart SDK to ^3.13.0, the version Flutter 3.47.0 ships. Stay on 0.1.0 if you need Dart 3.6–3.12.

0.1.0 #

Initial release.

  • Result<T> — a sealed type that is either Ok<T> or Err<T>, with map, flatMap, fold, getOrElse, valueOrNull and failureOrNull.
  • Unit / unit for operations whose success carries no payload.
  • Failure — a sealed hierarchy of ApiFailure, NetworkFailure, AuthFailure, CancelledFailure and UnknownFailure, each carrying title, message and optional referenceId and code.
  • FailureMapper / ChainedFailureMapper / CompositeFailureMapper / DefaultFailureMapper for turning SDK-specific errors into Failures without the package itself depending on any SDK.
  • guard and guardSync to convert a throwing body into a Result.
  • failureOrigin to label a failure with the call site that produced it.
1
likes
160
points
371
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A sealed Result type and a structured Failure hierarchy for Dart, so calls return a typed verdict instead of throwing across layer boundaries.

Homepage
Repository (GitHub)
View/report issues

Topics

#result #either #error-handling #functional #sealed

License

MIT (license)

Dependencies

equatable

More

Packages that depend on verdict