verdict 2.2.1
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.dartand two test files weren'tdart 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.zipandResult.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 viaonOkandonErr. - Added
Failure.toMap()/Failure.toJson(), a JSON-safe map of a failure's displayable fields for logging or an error response — deliberately excludingcauseandstackTrace. - Added
guardWithRetry, the retrying counterpart toguard, for a flaky call worth a second try before mapping the last error.
2.1.0 #
- Added
Result.collectFailures, the complement toResult.collect: gathers everyFailurein 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.ymlworkflow: pushing avX.Y.Ztag onmainverifies the tag matchespubspec.yamland has aCHANGELOG.mdentry, 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 upgradingverdictno longer forces the rest of a resolution forward. -
ResultgainedmapFailure,recover,recoverWith,getOrElseWith,valueOrThrow, theonOk/onErrside-effect taps, themapAsync/flatMapAsyncasync counterparts, and theResult.ok/Result.errconstructors. -
Result.collectturns anIterable<Result<T>>into aResult<List<T>>, short-circuiting on the first failure. -
flatten()collapses a nestedResult<Result<T>>. -
A
FutureResultextension mirrors the whole surface onFuture<Result<T>>, so an async pipeline chains forwards instead of nestingawaits. -
FailureExceptioncarries aFailureacross a throwing boundary; it is whatvalueOrThrowthrows. -
Failuregained optionalcauseandstackTracediagnostics, and every variant gainedcopyWith. Both new fields are excluded from equality, so failures compare the same whether or not the original error was kept. -
DefaultFailureMappernow records the error and its trace ascauseandstackTrace. -
The
mapperargument ofguard/guardSyncis now optional and defaults toDefaultFailureMapper.
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 eitherOk<T>orErr<T>, withmap,flatMap,fold,getOrElse,valueOrNullandfailureOrNull.Unit/unitfor operations whose success carries no payload.Failure— a sealed hierarchy ofApiFailure,NetworkFailure,AuthFailure,CancelledFailureandUnknownFailure, each carryingtitle,messageand optionalreferenceIdandcode.FailureMapper/ChainedFailureMapper/CompositeFailureMapper/DefaultFailureMapperfor turning SDK-specific errors intoFailures without the package itself depending on any SDK.guardandguardSyncto convert a throwing body into aResult.failureOriginto label a failure with the call site that produced it.