{"id":29093149,"url":"https://github.com/dev-cetera/df_flutter_services","last_synced_at":"2026-04-24T20:31:18.125Z","repository":{"id":300485977,"uuid":"1006308453","full_name":"dev-cetera/df_flutter_services","owner":"dev-cetera","description":"Includes service classes for Flutter to help with state management.","archived":false,"fork":false,"pushed_at":"2026-02-11T09:13:45.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-08T06:03:22.374Z","etag":null,"topics":["dart","flutter","services","state-management"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/df_flutter_services","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/dev-cetera.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["robmllze","dev-cetera"],"patreon":"RobertMollentze"}},"created_at":"2025-06-22T00:56:40.000Z","updated_at":"2026-02-11T09:13:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"0970dfb7-c7ec-4a59-8295-9fff233041e6","html_url":"https://github.com/dev-cetera/df_flutter_services","commit_stats":null,"previous_names":["robmllze/df_flutter_services"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dev-cetera/df_flutter_services","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-cetera%2Fdf_flutter_services","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-cetera%2Fdf_flutter_services/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-cetera%2Fdf_flutter_services/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-cetera%2Fdf_flutter_services/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-cetera","download_url":"https://codeload.github.com/dev-cetera/df_flutter_services/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-cetera%2Fdf_flutter_services/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32239441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: 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","flutter","services","state-management"],"created_at":"2025-06-28T08:06:33.921Z","updated_at":"2026-04-24T20:31:18.120Z","avatar_url":"https://github.com/dev-cetera.png","language":"Dart","funding_links":["https://github.com/sponsors/robmllze","https://github.com/sponsors/dev-cetera","https://patreon.com/RobertMollentze","https://www.buymeacoffee.com/dev_cetera","https://www.patreon.com/robelator"],"categories":[],"sub_categories":[],"readme":"[![banner](https://github.com/dev-cetera/df_flutter_services/blob/v0.1.8/doc/assets/banner.png?raw=true)](https://github.com/dev-cetera)\n\n[![pub](https://img.shields.io/pub/v/df_flutter_services.svg)](https://pub.dev/packages/df_flutter_services)\n[![tag](https://img.shields.io/badge/Tag-v0.1.8-purple?logo=github)](https://github.com/dev-cetera/df_flutter_services/tree/v0.1.8)\n[![buymeacoffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/dev_cetera)\n[![sponsor](https://img.shields.io/badge/Sponsor-grey?logo=github-sponsors\u0026logoColor=pink)](https://github.com/sponsors/dev-cetera)\n[![patreon](https://img.shields.io/badge/Patreon-grey?logo=patreon)](https://www.patreon.com/robelator)\n[![discord](https://img.shields.io/badge/Discord-5865F2?logo=discord\u0026logoColor=white)](https://discord.gg/gEQ8y2nfyX)\n[![instagram](https://img.shields.io/badge/Instagram-E4405F?logo=instagram\u0026logoColor=white)](https://www.instagram.com/dev_cetera/)\n[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://raw.githubusercontent.com/dev-cetera/df_flutter_services/main/LICENSE)\n\n---\n\n\u003c!-- BEGIN _README_CONTENT --\u003e\n\n## Summary\n\n`df_flutter_services` provides Flutter-specific service classes that respond to app lifecycle events (pause when backgrounded, resume when foregrounded). The base service classes (`Service`, `StreamService`) are in [df_di](https://pub.dev/packages/df_di) - this package adds `ObservedService` variants that integrate with Flutter's `WidgetsBindingObserver`.\n\nThis package is designed to work with [df_di](https://pub.dev/packages/df_di) for dependency injection and [df_pod](https://pub.dev/packages/df_pod) for reactive state.\n\n## Core Concepts\n\n| Class | Package | Purpose |\n|-------|---------|---------|\n| `Service` | df_di | Base service with init/pause/resume/dispose lifecycle |\n| `StreamService\u003cTData\u003e` | df_di | Service that manages a data stream |\n| `ObservedService` | df_flutter_services | Service that responds to Flutter app lifecycle events |\n| `ObservedStreamService\u003cTData\u003e` | df_flutter_services | StreamService + Flutter lifecycle integration |\n| `ObservedDataStreamService\u003cTData\u003e` | df_flutter_services | ObservedStreamService with automatic Pod (`pData`) updates |\n\n## Service Lifecycle States\n\n```\nNOT_INITIALIZED → init() → RUN_SUCCESS\n                            ↓\n                          pause() → PAUSE_SUCCESS\n                            ↓\n                          resume() → RESUME_SUCCESS\n                            ↓\n                          dispose() → DISPOSE_SUCCESS\n```\n\n## Quick Start\n\n### 1. Create a Basic Service\n\nFor services that don't need Flutter lifecycle integration, use `Service` from df_di:\n\n```dart\nimport 'package:df_di/df_di.dart';\n\nfinal class CounterService extends Service {\n  int _count = 0;\n  int get count =\u003e _count;\n\n  void increment() =\u003e _count++;\n\n  @override\n  TServiceResolvables\u003cUnit\u003e provideInitListeners(void _) =\u003e [\n    (_) {\n      _count = 0;\n      return syncUnit();\n    },\n  ];\n\n  @override\n  TServiceResolvables\u003cUnit\u003e providePauseListeners(void _) =\u003e [];\n\n  @override\n  TServiceResolvables\u003cUnit\u003e provideResumeListeners(void _) =\u003e [];\n\n  @override\n  TServiceResolvables\u003cUnit\u003e provideDisposeListeners(void _) =\u003e [\n    (_) {\n      print('CounterService disposed with count: $_count');\n      return syncUnit();\n    },\n  ];\n}\n```\n\n### 2. Create an ObservedDataStreamService with Reactive State\n\n`ObservedDataStreamService` automatically updates a `pData` Pod when the stream emits, and responds to Flutter app lifecycle:\n\n```dart\nimport 'package:df_flutter_services/df_flutter_services.dart';\n\nfinal class StockPriceService extends ObservedDataStreamService\u003cdouble\u003e {\n  final String symbol;\n  StockPriceService({required this.symbol});\n\n  // Access reactive state via pData: Pod\u003cOption\u003cResult\u003cdouble\u003e\u003e\u003e\n\n  @override\n  bool handlePausedState() =\u003e true;  // Pause stream when app backgrounds\n\n  @override\n  bool handleResumedState() =\u003e true; // Resume stream when app foregrounds\n\n  @override\n  Stream\u003cResult\u003cdouble\u003e\u003e provideInputStream() {\n    return Stream.periodic(\n      const Duration(seconds: 1),\n      (count) =\u003e Ok(100.0 + (count % 10) * 0.5),\n    );\n  }\n\n  @override\n  TServiceResolvables\u003cResult\u003cdouble\u003e\u003e provideOnPushToStreamListeners() =\u003e [\n    ...super.provideOnPushToStreamListeners(),\n    (data) {\n      if (data.isOk()) {\n        print('$symbol price: \\$${data.unwrap().toStringAsFixed(2)}');\n      }\n      return syncUnit();\n    },\n  ];\n}\n\n// Usage with PodBuilder:\nPodBuilder(\n  pod: stockService.pData,\n  builder: (context, _) {\n    final value = stockService.pData.getValue();\n    return value.fold(\n      ifNone: () =\u003e CircularProgressIndicator(),\n      ifSome: (result) =\u003e result.fold(\n        ifOk: (price) =\u003e Text('\\$${price.toStringAsFixed(2)}'),\n        ifErr: (error) =\u003e Text('Error: ${error.error}'),\n      ),\n    );\n  },\n)\n```\n\n### 3. Register Services with DI\n\nServices integrate seamlessly with `df_di`:\n\n```dart\n// Register with lifecycle callbacks\nDI.global.register\u003cStockPriceService\u003e(\n  StockPriceService(symbol: 'AAPL'),\n  onRegister: (service) =\u003e service.init(),\n  onUnregister: ServiceMixin.unregister, // Calls dispose() automatically\n);\n\n// Access anywhere\nfinal stockService = DI.global\u003cStockPriceService\u003e();\n\n// Or wait for async registration\nfinal stockService = await DI.global.untilSuper\u003cStockPriceService\u003e().unwrap();\n```\n\n## Best Practices\n\n1. **Always use `ServiceMixin.unregister` for `onUnregister`** - ensures `dispose()` is called\n2. **Use `ObservedDataStreamService` for reactive data** - automatic Pod updates and lifecycle handling\n3. **Override `provideDisposeListeners`** - clean up resources properly\n4. **Use `ObservedService` variants for background-sensitive services** - automatic pause/resume\n\n## Related Packages\n\n- [df_di](https://pub.dev/packages/df_di) - Dependency injection and base Service classes\n- [df_pod](https://pub.dev/packages/df_pod) - Reactive state containers\n- [df_safer_dart](https://pub.dev/packages/df_safer_dart) - Option, Result, Resolvable types\n\n\n\u003c!-- END _README_CONTENT --\u003e\n\n---\n\n🔍 For more information, refer to the [API reference](https://pub.dev/documentation/df_flutter_services/).\n\n---\n\n## 💬 Contributing and Discussions\n\nThis is an open-source project, and we warmly welcome contributions from everyone, regardless of experience level. Whether you're a seasoned developer or just starting out, contributing to this project is a fantastic way to learn, share your knowledge, and make a meaningful impact on the community.\n\n### ☝️ Ways you can contribute\n\n- **Find us on Discord:** Feel free to ask questions and engage with the community here: https://discord.gg/gEQ8y2nfyX.\n- **Share your ideas:** Every perspective matters, and your ideas can spark innovation.\n- **Help others:** Engage with other users by offering advice, solutions, or troubleshooting assistance.\n- **Report bugs:** Help us identify and fix issues to make the project more robust.\n- **Suggest improvements or new features:** Your ideas can help shape the future of the project.\n- **Help clarify documentation:** Good documentation is key to accessibility. You can make it easier for others to get started by improving or expanding our documentation.\n- **Write articles:** Share your knowledge by writing tutorials, guides, or blog posts about your experiences with the project. It's a great way to contribute and help others learn.\n\nNo matter how you choose to contribute, your involvement is greatly appreciated and valued!\n\n### ☕ We drink a lot of coffee...\n\nIf you're enjoying this package and find it valuable, consider showing your appreciation with a small donation. Every bit helps in supporting future development. You can donate here: https://www.buymeacoffee.com/dev_cetera\n\n\u003ca href=\"https://www.buymeacoffee.com/dev_cetera\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" height=\"40\"\u003e\u003c/a\u003e\n\n## LICENSE\n\nThis project is released under the [MIT License](https://raw.githubusercontent.com/dev-cetera/df_flutter_services/main/LICENSE). See [LICENSE](https://raw.githubusercontent.com/dev-cetera/df_flutter_services/main/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-cetera%2Fdf_flutter_services","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-cetera%2Fdf_flutter_services","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-cetera%2Fdf_flutter_services/lists"}