fluent_result 3.0.2
fluent_result: ^3.0.2 copied to clipboard

Dart native js
Flutter Android iOS web

Result is an object indicating success or failure of an operation.

Fluent Result #

Pub Version

Fluent Result is a lightweight Dart library developed to solve a common problem. It returns an object indicating success or failure of an operation instead of throwing/using exceptions.

Usage #

Simple Non-Generic Result #

Result result = Result.success();
Result result = Result.fail(ResultError('a fail reason'));
Result result = Result.withErrorMessage('a fail reason');
Result result = Result.withException(MyException('exception description'));

Generic Result #

ResultOf<MyObject> result = ResultOf.success(MyObject());
MyObject value = result.value;
ResultOf<MyObject> result = ResultOf.fail<MyObject>(ResultError('a fail reason'));
MyObject value = result.value;
Result result = ResultOf.withErrorMessage<MyObject>('a fail reason');
Result result = ResultOf.withException(MyException<MyObject>('exception description'));

Converting Result to another #

To convert one success result to another success result has to be provided a valueConverter

final anotherResult =
    result.toResult(valueConverter: (customer) => User(customer.id));

To convert one fail result to another fail result

final anotherResult = failResult.toResult<Customer>();

Contributing #

We accept the following contributions:

  • Improving documentation
  • Reporting issues
  • Fixing bugs

Maintainers #

  • Andrew Piterov
0
likes
100
pub points
11%
popularity

Result is an object indicating success or failure of an operation.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

piterov1990@gmail.com

License

MIT (LICENSE)

Dependencies

meta

More

Packages that depend on fluent_result