{"id":32275769,"url":"https://github.com/mintware-de/catalyst","last_synced_at":"2025-10-22T23:54:47.765Z","repository":{"id":56826940,"uuid":"129546388","full_name":"mintware-de/catalyst","owner":"mintware-de","description":"The only dependency injection container for Dart you'll ever need","archived":false,"fork":false,"pushed_at":"2022-12-29T15:35:03.000Z","size":51,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T23:54:37.374Z","etag":null,"topics":["catalyst","dart","dependency-injection","register","service-container"],"latest_commit_sha":null,"homepage":"https://pub.dartlang.org/packages/catalyst","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/mintware-de.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}},"created_at":"2018-04-14T19:05:36.000Z","updated_at":"2023-03-10T14:20:46.000Z","dependencies_parsed_at":"2023-01-31T09:15:54.283Z","dependency_job_id":null,"html_url":"https://github.com/mintware-de/catalyst","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mintware-de/catalyst","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintware-de%2Fcatalyst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintware-de%2Fcatalyst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintware-de%2Fcatalyst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintware-de%2Fcatalyst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mintware-de","download_url":"https://codeload.github.com/mintware-de/catalyst/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintware-de%2Fcatalyst/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280534673,"owners_count":26346714,"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","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["catalyst","dart","dependency-injection","register","service-container"],"created_at":"2025-10-22T23:54:46.376Z","updated_at":"2025-10-22T23:54:47.760Z","avatar_url":"https://github.com/mintware-de.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Catalyst is retro 🥱 Head over to Catalyst Builder, the more powerful and cross platform supported successor of this package. https://github.com/mintware-de/catalyst_builder\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[![GitHub license](https://img.shields.io/github/license/mintware-de/catalyst.svg)](https://github.com/mintware-de/catalyst/blob/master/LICENSE)\n[![Travis](https://img.shields.io/travis/mintware-de/catalyst.svg)](https://travis-ci.org/mintware-de/catalyst)\n[![Pub](https://img.shields.io/pub/v/catalyst.svg)](https://pub.dartlang.org/packages/catalyst)\n[![Coverage Status](https://coveralls.io/repos/github/mintware-de/catalyst/badge.svg?branch=master)](https://coveralls.io/github/mintware-de/catalyst?branch=master)\n\n# Catalyst\n\nCatalyst is a dependency injection container for the dart language.\nIt's fast, reliable and easy to understand.\n\n## 📦 Installation\nAdd the following to your `pubspec.yaml`:\n```yaml\ndependencies:\n  catalyst: ^3.0.0\n```\n\nThen run `pub get`\n\n## 💡 Usage\n\n### Importing\n```dart\nimport 'package:catalyst/catalyst.dart';\n```\n\n### Register Services\nTo register a service you have to call the `register`-method.\n\n```\nContainer.register(String id, dynamic service, [arguments = const \u003cdynamic\u003e[]])\n```\n\n|  Parameter | Description                                                                    | Example              |\n|:-----------|:-------------------------------------------------------------------------------|:---------------------|\n| id         | The unique id of the service                                                   | app.my_service       |\n| service    | The service target                                                             | `(int a) =\u003e a * 2`   |\n| arguments  | The arguments for the service. Entries with @-prefix are service references    | `[1, 'foo', bar]`    |\n\n#### Register a service with static arguments\nSince not all services need an service injection, the arguments array also supports static entries.\n\n```dart\nimport 'package:catalyst/catalyst.dart';\n\nvoid main() {\n  var container = Container();\n\n  container.register('app.my_service', (String name) {\n    return 'Hello $name';\n  }, ['Your Name']);\n\n  var knownServices = container.registeredServices; // Contains the registered Service\n}\n```\n\n#### Register a service with a service dependency\nIn most cases you need another registered service in your service.\nIn that case you can pass the service name with a @-prefix to reference to it.\nThe (sub-) dependencies are solved recursively.\n\n```dart\nimport 'package:catalyst/catalyst.dart';\n\nvoid main() {\n  var container = Container();\n\n  container.register('app.another_service', () {\n    return {'name': 'Jane', 'age': '24'};\n  });\n\n  container.register('app.my_service', (dynamic anotherService) {\n    return \"Name: ${anotherService['name']}, Age: ${anotherService['age']}\";\n  }, ['@app.another_service']);\n\n  print(container.get('app.my_service')); // Outputs \"Name: Jane, Age: 24\"\n}\n```\n\n#### Register a class as a service\nYou can also register a class as a service. If the service is loaded, the constructor gets called with the dependencies.\n\n```dart\nimport 'package:catalyst/catalyst.dart';\n\nmain() {\n  var container = Container();\n\n  // Register the first service\n  container.register('namer', () =\u003e 'John Doe');\n\n  // Register the second service. The constructor will be called with the passed arguments\n  container.register('greeter', Greeter, ['@namer']);\n\n  // Retrieve the greeter\n  var greeter = container.get('greeter');\n\n  // Greet\n  print(greeter.greet()); // Outputs \"Hello, my Name is John Doe!\"\n}\n\nclass Greeter {\n  String name;\n\n  Greeter(this.name) {}\n\n  String greet() {\n    return \"Hello, my Name is $name!\";\n  }\n}\n```\n\n### Load a service\nTo load a service you have to call the `get`-method.  \nOnce a service is loaded, it remains in memory at runtime.\nWhen the same service is loaded again, the first instance is returned.\n\n```\nContainer.get(String id)\n```\n|  Parameter | Description                     | Example        |\n|:-----------|:--------------------------------|:---------------|\n| id         | The unique id of the service.   | app.my_service |\n\n\n```dart\nimport 'package:catalyst/catalyst.dart';\n\nvoid main() {\n  var container = Container();\n\n  // Register the first service\n  container.register('namer', () =\u003e 'Catalyst');\n\n  container.get('namer'); // returns \"Catalyst\"\n}\n```\n\n### Add Parameters\nThe service container also supports static parameters.  \nYou can add a parameter using the `addParameter`-method\n```\nContainer.addParameter(String name, dynamic value)\n```\n|  Parameter | Description                       | Example        |\n|:-----------|:----------------------------------|:---------------|\n| name       | The unique name of the parameter. | database.host  |\n| value      | The parameter value               | localhost      |\n\nTo pass a parameter to a service, add before and after the name a '%': `%name.of.the.parameter%`\n```dart\n\nimport 'package:catalyst/catalyst.dart';\nvoid main() {\n  var container = Container();\n  container.addParameter('database.host', 'localhost');\n\n  container.register('db.context', (String hostname) {\n    return 'Connecting to $hostname';\n  }, ['%database.host%']);\n\n  print(container.get('db.context')); // Outputs \"Connecting to localhost\"\n}\n```\n\n## 🔌 Service auto wiring\nCatalyst supports auto wiring of services.\nThat means, that you only need to register the service without passing depending service names as arguments.\n(Strong typing is required).\n \nFor example:\n```dart\nimport 'package:catalyst/catalyst.dart';\n\nmain() {\n  container = Container();\n  container.register('greeter', SimpleGreeter);\n  container.register('greeting_printer', (SimpleGreeter greeter) {\n    print(greeter.greet('Catalyst'));\n  });\n\n  container.get('greeting_printer'); // Outputs \"Hello from Catalyst!\"\n}\n\nclass SimpleGreeter {\n  String greet(String name) {\n    return \"Hello from $name!\";\n  }\n}\n```\n\nYou can disable this behaviour with setting `Container.autoWire = false;`\n\n## 🔬 Testing\n\n```bash\n$ pub run test\n```\n\n## 🤝 Contribute\nFeel free to fork and add pull-requests 🤓\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintware-de%2Fcatalyst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmintware-de%2Fcatalyst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintware-de%2Fcatalyst/lists"}