resultify

所属分类:Dart语言编程
开发工具:Dart
文件大小:0KB
下载次数:0
上传日期:2023-12-01 16:56:36
上 传 者sh-1993
说明:  用于面向结果编程的Dart包,为result类型提供简化错误处理的方便方法。
(A Dart package for result-oriented programming, providing Result type with convenient methods for streamlined error handling.)

文件列表:
CHANGELOG.md (464, 2023-12-11)
LICENSE (1507, 2023-12-11)
analysis_options.yaml (1038, 2023-12-11)
example/ (0, 2023-12-11)
example/resultify_example.dart (2048, 2023-12-11)
lib/ (0, 2023-12-11)
lib/resultify.dart (469, 2023-12-11)
lib/src/ (0, 2023-12-11)
lib/src/resultify_base.dart (2042, 2023-12-11)
pubspec.yaml (304, 2023-12-11)
test/ (0, 2023-12-11)
test/resultify_test.dart (1840, 2023-12-11)

# Resultify A Dart package for result-oriented programming, providing a `Result` type with convenient methods for streamlined error handling. ## Usage To use this package, add `resultify` as a [dependency in your `pubspec.yaml`](https://dart.dev/guides/packages): ```yaml dependencies: resultify: ``` Now you can import the package in your Dart code: ```dart import 'package:resultify/resultify.dart'; ``` ## Result Type The `Result` type encapsulates either a successful result (`R`) or an error (`E`). ```dart Result 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](example/resultify_example.dart) directory. ## Issues and Contributions Feel free to report issues or contribute to the project on [GitHub](https://github.com/intales/resultify).

近期下载者

相关文件


收藏者