fluent_result 9.0.0
fluent_result: ^9.0.0 copied to clipboard
A fluent Result type for Dart that returns success/failure instead of throwing, with a global observability seam for crash reporting.
9.0.0 #
Breaking #
- The core is now a Dart 3 sealed
Result<T>withOk<T>(non-nullvalue) /Err<T>.ResultOf<T>is removed; value-free success isResult<void>. Ok.valueis non-nullT(wasResultOf<T>.value : T?). Read it via pattern matching /valueOrNull/valueOr.- Single-error model:
List<ResultError>,errors(plural),add/addAll,contains<T>/get<T>are removed.error(singular) anderrorMessageremain. foldis now value-returning (R fold<R>(onOk, onErr)); the 8.xvoid fold({onFail, onSuccess})is gone.matchis its named-parameter form.- A
ResultMatcherbuildnow returns aResultError(was aResultOf<dynamic>); the typedErr<T>is wrapped at thetry*call site. - A thrown
Errornot claimed by a matcher now rethrows fromtry*/guard(reaching the Zone / crash reporter) instead of becoming a silent fail. - SDK floor raised to
>=3.0.0.
Removed #
- The 8.5 deprecated
exceptionHandler,exceptionHandlerMatchers,logSuccessResult. asResult(extension onObject),ResultException, the vestigialResultConfig()factory.- The
collectiondependency — the package now has zero runtime dependencies.
Added #
Ok/Errsealed variants with exhaustiveswitch; value-based, symmetric==/hashCode.ResultError.code/cause/stackTrace;runtimeTypein equality.- Value-returning
fold+match;Err.cast<R>; combinatorsmap/flatMap/flatMapAsync/recover/mapError/valueOr/getOrElse. Error-rethrow policy with a matcher escape hatch (claim anErrortype to convert it toErr).
Migration #
ResultOf<T>→Result<T>;result.value!→ pattern matching orvalueOrNull/valueOr.- Move any
exceptionHandlerreporting toonException; replaceexceptionHandlerMatchersmaps withmatchers. - For
Error-derived third-party exceptions (e.g.DioError extends Error), add aResultMatcher((e) => e is Error, ...)or they will rethrow.
8.5.0 #
- [Add] Global observability seam
ResultConfig.onException(no-op by default) — the single place to wire crash reporting (e.g. Sentry). Unexpected caught exceptions are reported exactly once. - [Add]
ResultMatcher+ResultConfig.matchers: ordered, subtype-aware error classification with anexpectedflag (expected errors are never reported). - [Add]
ResultConfig.onSuccess,failBuilder, andreset()(call in testtearDownto avoid global-config leakage). - [Add]
onErrorWithStackparameter ontrySync/tryAsync. - [Add]
ResultOf.guard/guardAsyncto wrap a plain value-returning body. - [Add] Combinators on
ResultOf<T>:flatMap,flatMapAsync,match,valueOr,getOrElse,recover,mapError. - [Change]
failIf/okIfroute throughfailBuilder— validation failures are never reported. - [Change]
fail/failWithreturnResultOf<T>(wasResultOf<T?>) — covariant, non-breaking. - [Change] Caught and successful results are no longer logged by default; the default
exceptionHandlerMatchersis now empty. - [Change] SDK lower bound raised to
>=2.14.0. - [Deprecate]
exceptionHandler,exceptionHandlerMatchers,logSuccessResult— still honored, but preferonException+matchers+onSuccess. - [Remove]
loggerandquiverdependencies. - [Docs] add a runnable
example/, fill the public API dartdoc, and add pub.dev metadata (topics,repository,issue_tracker, correcteddescription).
Migration
- If your
ResultConfig.exceptionHandlerreported errors itself, move that reporting intoResultConfig.onExceptionto avoid double-reporting. failIf/okIfnow route throughResultConfig.failBuilderinstead ofexceptionHandler; if you customizedexceptionHandlerto shape their output, setfailBuilderinstead.- For
Error-derived third-party exceptions (e.g.DioError extends Error), match with(e) => e is Error— thee is Exceptioncatch-all does not match them.
8.4.1 #
- [Fix]
Result.hashCodeis now stable and contract-correct, so equal Results share a hash code and work asSet/Mapkeys - [Fix]
ResultOf.map()no longer drops all but the first error when mapping a multi-error fail result - [Fix]
foldWithValue/mapthrow a clearStateErrorinstead of an opaqueTypeErrorwhen a non-nullable success value isnull - [Docs] correct README
exceptionHandlerMatchersmatcher signature, nullableResultOf.value, andResult.failWithusage
8.4.0 #
- [Fix] can pass
nullinsuccessWith(null)
8.3.0 #
- add
onFinallymethod toResultOfandResult - update
loggerdependency to^2.2.0
8.2.0 #
- update
loggerdependency
8.1.0 #
- downgrade
collection: ^1.17.1
8.0.0 #
- [Fix] logging stack trace.
- [Update] dependencies.
7.2.0 #
- [Add] exception handler matchers.
7.1.1 #
- [Add] onError in
trySync/tryAsyncfor error handler customization.
7.1.0 #
- [Add] logSuccessResult into
ResultConfig - [Change] errorMessage now is non-nullable, by default is empty string.
7.0.0 #
- [Add]
ResultConfigto customizeexceptionHandler - [Fix]
tries
6.0.0 #
- [Add]
success,successWith,failmethods - [Add]
trySync,tryAsyncmethods - [Change]
toResultintomap
5.0.0 #
Breaking changes
ResultErrorhas not const constructor anymore.
Updates
- Use
withErrorandwithErrorsinstead offailandfailsrespectively. - [Add] folding onFail and onSuccess with
fold(onFail, onSuccess). - [Add] mapping any object to
ResultOf<T>withtoResult(). - [Add]
failIf(condition, reason)andokIf(condition, failReason).
4.3.0 #
- [Fix]
contains<T>() - [Add] getting specific error from collection by
get<T>
4.2.0 #
- [Fix]
contains<T>()
4.1.0 #
- [Add] errors collection
4.0.1 #
- [Migrate] to null-safety
4.0.0 #
- [Update] dependencies for migration to null-safety
3.0.2 #
- Add
withErrorMessage(String)method toResultOf - Add
withException(Exception)method toResultOf
3.0.1 #
- [Add]
withErrorMessage(String)method toResult - [Add]
withException(Exception)method toResult
3.0.0+1 #
Correct README.md
3.0.0 #
- [Add]
ResultErrorobject that describes a error and allows the errors to be typed.
2.0.0+1 #
Correct README.md
2.0.0 #
- [Add]
ResultOf<T>for generic Result to hold value of T. - [Remove]
flutterdependency
1.0.0+1 #
- [Add] correct description
1.0.0 #
Initial Version of the library.
- Includes the ability to create Success and Fail Results
- Includes the ability to create Generic Result with value