verdict 1.1.0 copy "verdict: ^1.1.0" to clipboard
verdict: ^1.1.0 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.

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
186
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