{"id":20612863,"url":"https://github.com/rodrigobertotti/stream_d","last_synced_at":"2026-05-18T17:03:58.295Z","repository":{"id":206874144,"uuid":"717885134","full_name":"RodrigoBertotti/stream_d","owner":"RodrigoBertotti","description":"Stream that triggers the onDone event handler even when cancel() is called from a subscription. You can also add multiple onDone listeners. StreamD is a wrapper on the default Dart Stream, with an additional listenD method, but StreamD doesn't work as StreamBuilder parameter.","archived":false,"fork":false,"pushed_at":"2023-11-14T20:14:17.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-07-08T18:11:30.678Z","etag":null,"topics":["flutter","stream"],"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/RodrigoBertotti.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,"zenodo":null}},"created_at":"2023-11-12T22:07:42.000Z","updated_at":"2024-11-23T03:12:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e2e47c9-e700-43eb-b9e8-1575a2513c82","html_url":"https://github.com/RodrigoBertotti/stream_d","commit_stats":null,"previous_names":["rodrigobertotti/stream_d"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/RodrigoBertotti/stream_d","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodrigoBertotti%2Fstream_d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodrigoBertotti%2Fstream_d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodrigoBertotti%2Fstream_d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodrigoBertotti%2Fstream_d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RodrigoBertotti","download_url":"https://codeload.github.com/RodrigoBertotti/stream_d/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RodrigoBertotti%2Fstream_d/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33184769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["flutter","stream"],"created_at":"2024-11-16T11:08:08.687Z","updated_at":"2026-05-18T17:03:58.290Z","avatar_url":"https://github.com/RodrigoBertotti.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StreamD\n\nStream that triggers the `onDone` event handler even when `cancel()` is called from a subscription.\nYou can also add multiple `onDone` listeners.\n`StreamD` is a wrapper on the default Dart Stream, with an additional `listenD` method,\nbut `StreamD` doesn't work as `StreamBuilder` parameter.\n\n## About StreamD\n\nThere's a minor hassle when managing Dart Streams:\n- the `onDone` event handler is not triggered when `cancel()` is called from a `StreamSubscription`,\nso it may be tricky to identify the exact moment when a `StreamSubscription` became no longer active if\nwe don't have access to its `StreamController` on a specific layer of the App.\n\nThe solution when calling `listenD`\n- `onDone` event handler is always triggered once the stream is no longer active, even when `cancel()` is called from a `StreamSubscription`.\n\n`StreamD` also allows you to add a listener with `addOnDone` that won't replace the previous `onDone` callback.\n\n## Comparison\n\n```dart\nfinal controller1 = StreamController();\nfinal defaultStream = controller1.stream;\nfinal defaultStreamSubscription = defaultStream.listen((event) {});\ndefaultStreamSubscription.onDone(() {\nprint(\"(2) Default Stream: onDone was triggered!\");\n});\nprint(\"(1) Default Stream: let's call cancel() on the subscription...\");\ndefaultStreamSubscription.cancel();\n\nfinal controller2 = StreamController();\nfinal streamD = StreamD(controller2.stream);\nfinal StreamSubscriptionD streamSubscriptionD = streamD.listenD((event) {});\nstreamSubscriptionD.addOnDone(() {\nprint(\"(2) With StreamD: onDone was triggered!\");\n});\nprint(\"(1) With StreamD: let's call cancel() on the subscription...\");\nstreamSubscriptionD.cancel();\n```\n### Output:\n\n    (1) Default Stream: let's call cancel() on the subscription...\n    (1) With StreamD: let's call cancel() on the subscription...\n    (2) With StreamD: onDone was triggered!\n\n### :warning: Limitation\n\n**StreamD doesn't work as StreamBuilder parameter**, so calling `listen(..)` will give you an error,\nplease use `listenD(..)` instead or use the default Dart Stream.\n\n## Getting started\n\n    dependencies:\n      flutter:\n        sdk: flutter\n            \n        # Add this line:\n        stream_d: ^0.3.0\n\n### Initializing a StreamD\n\n```dart\nfinal streamD = StreamD(stream);\n```\n\n### Listening\n```dart\nfinal StreamSubscriptionD subscription = streamD.listenD((event) {\n    print(event);\n});\n```\n### Adding onDone listener to a subscription\n```dart\nfinal StreamSubscriptionD subscription = streamD.listenD((event) {});\nsubscription.addOnDone(() {\n    print(\"onDone was called!\");\n});\n```\n\n## License\n\n[MIT](LICENSE)\n\n## Contacting me\n\n📧 rodrigo@wisetap.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigobertotti%2Fstream_d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodrigobertotti%2Fstream_d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodrigobertotti%2Fstream_d/lists"}