{"id":26382854,"url":"https://github.com/minikin/result_type","last_synced_at":"2026-03-15T07:10:59.970Z","repository":{"id":37926733,"uuid":"503329825","full_name":"minikin/result_type","owner":"minikin","description":"💊 Result Type for Dart represents either a success or a failure, including an associated value in each case.","archived":false,"fork":false,"pushed_at":"2024-04-30T09:49:56.000Z","size":86,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-31T15:12:34.684Z","etag":null,"topics":["dart","either","flutter","functional-programming","result","result-type"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/result_type","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/minikin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2022-06-14T11:27:35.000Z","updated_at":"2025-02-12T14:12:33.000Z","dependencies_parsed_at":"2025-03-17T06:19:19.221Z","dependency_job_id":"dcc70064-9faf-4b08-b3e1-48d766900e31","html_url":"https://github.com/minikin/result_type","commit_stats":{"total_commits":33,"total_committers":1,"mean_commits":33.0,"dds":0.0,"last_synced_commit":"598efad0f2844ba58c0a6cdd38c3c6a573bb88cc"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/minikin/result_type","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minikin%2Fresult_type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minikin%2Fresult_type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minikin%2Fresult_type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minikin%2Fresult_type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minikin","download_url":"https://codeload.github.com/minikin/result_type/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minikin%2Fresult_type/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30537204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-15T06:53:40.532Z","status":"ssl_error","status_checked_at":"2026-03-15T06:51:47.131Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dart","either","flutter","functional-programming","result","result-type"],"created_at":"2025-03-17T06:19:16.293Z","updated_at":"2026-03-15T07:10:59.944Z","avatar_url":"https://github.com/minikin.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eResult Type for Dart\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/minikin/result_type/actions\"\u003e\n    \u003cimg src=\"https://github.com/minikin/result_type/actions/workflows/build.yml/badge.svg\" alt=\"CI Status\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://codecov.io/gh/minikin/result_type\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/minikin/result_type/branch/main/graph/badge.svg?token=dpljQutAnj\"/\u003e\n  \u003c/a\u003e\n\n   \u003ca href=\"https://github.com/minikin/result_type/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"Result Type is released under the MIT license.\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/minikin/result_type/blob/main/CODE_OF_CONDUCT.md\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\" alt=\"PRs welcome!\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# Content\n\n- [Content](#content)\n  - [Features](#features)\n  - [Requirements](#requirements)\n  - [Install](#install)\n  - [Example](#example)\n  - [Support](#support)\n  - [License](#license)\n\n## Features\n\nResult is a type that represents either [Success](https://github.com/minikin/result_type/blob/main/lib/src/success.dart) or [Failure](https://github.com/minikin/result_type/blob/main/lib/src/failure.dart).\n\nInspired by [functional programming](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Either.html), [Rust](https://doc.rust-lang.org/std/result/enum.Result.html) and [Swift](https://developer.apple.com/documentation/swift/result).\n\n## Requirements\n\n- Dart: 3.3.0+\n\n## Install\n\n```yaml\ndependencies:\n  result_type: ^1.0.0\n```\n\n## Example\n\nThe detailed example can be found at [result_type/example/example.dart](https://github.com/minikin/result_type/blob/main/example/example.dart).\n\n```dart\nimport 'dart:math';\n\nimport 'package:http/http.dart' as http;\nimport 'package:result_type/src/result.dart';\n\nimport 'imaginary_service.dart';\nimport 'photo.dart';\nimport 'photos_service.dart';\n\nfinal client = http.Client();\nfinal random = Random();\n\nvoid main() async {\n  final photosResult = await PhotosService.getPhotos(client);\n\n  final photosOr = photosResult.unwrapOr([Photo.initial()]);\n\n  print(photosOr);\n\n  /// Use `switch` to handle both success and failure.\n  final _ = switch (photosResult) {\n    Success(value: final data) =\u003e data,\n    Failure(value: final error) =\u003e 'Error: $error'\n  };\n\n  /// Do something with successful operation results or handle an error.\n  if (photosResult.isSuccess) {\n    print('Photos Items: ${photosResult.success}');\n  } else {\n    print('Error: ${photosResult.failure}');\n  }\n\n  // Chain multiple asynchronous operations.\n  final result1 = await ImaginaryService.fetchData1();\n  final result2 = await ImaginaryService.fetchData2(result1.success);\n  final result3 = await ImaginaryService.fetchData2(result2.success);\n\n  // Print the result of the last operation: `Success: Default Data`\n  print(result3.unwrapOr('Default Data'));\n\n  // This will throw an exception as `_handleResult`\n  // has a case with 'Wrong Data'.\n  //print(result3.unwrap());\n\n  String length(String string) =\u003e string.length.toString();\n\n  final unwrapOrElse = result3.unwrapOrElse('Default (((((Data)))))', length);\n  // Print the result of the last operation: `22`\n  print(unwrapOrElse);\n\n  /// Apply transformation to successful operation results or handle an error.\n  if (photosResult.isSuccess) {\n    final items = photosResult\n        .map(\n          (i) =\u003e i.where(\n            (j) =\u003e j.title.length \u003e 60,\n          ),\n        )\n        .success;\n    print('Number of Long Titles: ${items.length}');\n  } else {\n    print('Error: ${photosResult.failure}');\n  }\n\n  /// In this example, note the difference in the result of using `map` and\n  /// `flatMap` with a transformation that returns an result type.\n  Result\u003cint, Exception\u003e getNextInteger() =\u003e Success(random.nextInt(4));\n  Result\u003cint, Exception\u003e getNextAfterInteger(int n) =\u003e\n      Success(random.nextInt(n + 1));\n\n  final nextIntegerNestedResults = getNextInteger().map(getNextAfterInteger);\n  print(nextIntegerNestedResults.runtimeType);\n  // Prints: Success\u003cResult\u003cint, Error\u003e, dynamic\u003e\n\n  final nextIntegerUnboxedResults =\n      getNextInteger().flatMap(getNextAfterInteger);\n  print(nextIntegerUnboxedResults.runtimeType);\n  // Prints: Success\u003cint, Error\u003e\n\n  /// Use completion handler / callback style API if you want to.\n  await PhotosService.getPhotos(client)\n    ..result((photos) {\n      // print('Photos: $photos');\n    }, (error) {\n      print('Error: $error');\n    });\n}\n\n```\n\nTo see examples of the following package in action:\n\n```sh\ncd example \u0026\u0026 dart run\n```\n\n## Support\n\nPost issues and feature requests on the GitHub [issue tracker](https://github.com/minikin/result_type/issues).\n\n## License\n\nThe source code is distributed under the MIT license.\nSee the [LICENSE](https://github.com/minikin/result_type/blob/main/LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminikin%2Fresult_type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminikin%2Fresult_type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminikin%2Fresult_type/lists"}