- This version aims to reduce the
Result
boilerplate by making theFailure
type Exception by default. This will free the Result from having to typeFailure
, making the declaration smaller.
If there is a need to type Failure
, use ResultDart
.
Added
- Introduced
typedef
forResult<S>
andAsyncResult<S>
to simplify usage:Result<S>
is a simplified alias forResultDart<S, Exception>
.AsyncResult<S>
is a simplified alias forAsyncResultDart<S, Exception>
.
Changed
- Replaced
Result
class withResultDart
as the base class for all results.- Default failure type for
ResultDart
is nowException
. - This change reduces boilerplate and improves usability by eliminating the need to specify the failure type explicitly in most cases.
- Default failure type for
Removed
- Remove factories
Result.success
andResult.failure
.
Migration Guide
- In version >=2.0.0, the Failure typing is by default an
Exception
, but if there is a need to type it, useResultDart<Success, Failure>
.
only Success
type:
// Old
Result<int, Exception> myResult = Success(42);
// NEW
Result<int> myResult = Success(42);
with Success
and Failure
types:
// Old
Result<int, String> myResult = Success(42);
// NEW
ResultDart<int, String> myResult = Success(42);