resultify 0.4.0 copy "resultify: ^0.4.0" to clipboard
resultify: ^0.4.0 copied to clipboard

A Dart package for result-oriented programming, providing Result<R, E> type with convenient methods for streamlined error handling.

Resultify #

A Dart package for result-oriented programming, providing a Result<R, E> type with convenient methods for streamlined error handling.

Usage #

To use this package, add resultify as a dependency in your pubspec.yaml:

dependencies:
    resultify: <latest-version>

Now you can import the package in your Dart code:

import 'package:resultify/resultify.dart';

Result Type #

The Result<R, E> type encapsulates either a successful result (R) or an error (E).

Result<int, String> divide(int a, int b) {
    if (b == 0) return Result.error("Cannot divide by zero");
    return Result.success(a ~/ b);
}

Convinient methods #

The package provides convenient methods for working with results:

  • getResultOrDefault: Gets the result or a default value.
  • getErrorOrDefault: Gets the error or a default value.
  • match: Matches the result, invoking callbacks based on success or error.
  • wrap: Executes a function and wraps the result, handling exceptions.

For more examples and detailed usage, please refer to the example directory.

Issues and Contributions #

Feel free to report issues or contribute to the project on GitHub.

1
likes
140
pub points
36%
popularity

Publisher

verified publisherintales.it

A Dart package for result-oriented programming, providing Result<R, E> type with convenient methods for streamlined error handling.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on resultify