{"id":20772770,"url":"https://github.com/leadcodedev/result_pattern","last_synced_at":"2025-10-17T22:11:30.844Z","repository":{"id":249512912,"uuid":"819339369","full_name":"LeadcodeDev/result_pattern","owner":"LeadcodeDev","description":"Provides a robust way of handling operations that may succeed or fail.","archived":false,"fork":false,"pushed_at":"2024-07-25T22:20:26.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T00:36:09.308Z","etag":null,"topics":["error","patterns","result"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LeadcodeDev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-24T10:01:41.000Z","updated_at":"2024-11-18T16:14:31.000Z","dependencies_parsed_at":"2024-07-26T00:35:00.375Z","dependency_job_id":null,"html_url":"https://github.com/LeadcodeDev/result_pattern","commit_stats":null,"previous_names":["leadcodedev/result_pattern"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Fresult_pattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Fresult_pattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Fresult_pattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Fresult_pattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeadcodeDev","download_url":"https://codeload.github.com/LeadcodeDev/result_pattern/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243112187,"owners_count":20238180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error","patterns","result"],"created_at":"2024-11-17T12:22:59.975Z","updated_at":"2025-10-17T22:11:25.825Z","avatar_url":"https://github.com/LeadcodeDev.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Result Pattern\n\nThe `Result Pattern` package for Dart provides a robust way of handling operations that may succeed or fail.\nBy encapsulating the result of an operation in a `Result` object, this package allows developers to write code that is\nmore predictable, safer, easier to understand and maintain.\n\n## Benefits\n\n- **Improved error handling**: Encapsulates success and failure results in a single, predictable type.\n  predictable type.\n- **Cleaner code**: Reduces the need for try-catch blocks, making the code base cleaner and more readable.\n- **Composable**: Makes it easy to chain several operations together and manage their results in a unified way.\n\n## Installation\n\nAdd `result_pattern` to your `pubspec.yaml` file:\n\n```bash\ndart pub add result_pattern\n```\n\n## Utilisation\n\n### Basique\n\n```dart\nimport 'package:result_pattern/result_pattern.dart';\n\nvoid main() {\n  final result = Result.ok(42);\n  expect(result.unwrap(), 42);\n\n  final value = switch (result) {\n    Ok(:final value) =\u003e value,\n    Err(:final error) =\u003e throw error,\n  };\n\n  expect(value, 42);\n}\n```\n\n### Future usage\n\n```dart\nimport 'package:result_pattern/result_pattern.dart';\n\nAsyncResult\u003cint, Exception\u003e getOkResult() =\u003e Result.ok(42);\n\nFuture\u003cvoid\u003e main() async {\n  expect(await future.unwrap(), 42);\n\n  // Use pattern matching to extract the value or throw an error\n  final value = switch (await future) {\n    Ok(:final value) =\u003e value,\n    Err(:final error) =\u003e throw error,\n  };\n\n  // Use the match method to handle error cases\n  final value = await getOkResult()\n    .expect('Error message');\n\n  expect(value, 42);\n}\n```\n\n## Contribution\n\nContributions are welcome!\nFeel free to submit a pull request or open an issue if you have suggestions or find bugs.\n\n## License\n\nThis package is licensed under the MIT license. See the LICENSE file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleadcodedev%2Fresult_pattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleadcodedev%2Fresult_pattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleadcodedev%2Fresult_pattern/lists"}