{"id":21377185,"url":"https://github.com/odroe/rc","last_synced_at":"2026-01-20T03:33:46.641Z","repository":{"id":61975499,"uuid":"533641236","full_name":"odroe/rc","owner":"odroe","description":"RC is a configuration/collection manager that uses `.` (dot) to set and read collection contents.","archived":false,"fork":false,"pushed_at":"2024-10-04T17:38:19.000Z","size":76,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T14:22:13.443Z","etag":null,"topics":["dart","flutter"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odroe.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":"2022-09-07T06:45:25.000Z","updated_at":"2024-10-04T17:38:16.000Z","dependencies_parsed_at":"2024-11-05T15:39:13.032Z","dependency_job_id":"fd904032-61c4-42d0-84ae-a6175aab22cc","html_url":"https://github.com/odroe/rc","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":0.09090909090909094,"last_synced_commit":"e7a9c4fd091280f827d18a2575ea131d84d064d5"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odroe%2Frc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odroe%2Frc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odroe%2Frc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odroe%2Frc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odroe","download_url":"https://codeload.github.com/odroe/rc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225489502,"owners_count":17482378,"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":["dart","flutter"],"created_at":"2024-11-22T09:19:24.556Z","updated_at":"2026-01-20T03:33:46.586Z","avatar_url":"https://github.com/odroe.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RC\n\nRC is a configuration/collection manager that uses `.` (dot) to set and read collection contents. And it is designed with loaders to load collections from various locations such as environment variables.\n\nRC's name uses the acronym of `Runtime Configure`/`Real Collection`. You can use it as a collection container, and you can also use it as a configuration manager with a loader.\n\n\u003e What is a collection? Collection is a concept, usually Map/List/Set/Iterable are all collections.\n\n## Installation\n\nUse command line:\n\n```bash\ndart pub add rc\n```\n\nOr update your `pubspec.yaml` file:\n\n```yaml\ndependencies:\nrc: latest\n```\n\n## Quick Start\n\n```dart\nimport 'package:rc/rc.dart';\n\nfinal config = RC(init: {\n    'app': {\n        debug: true,\n    }\n});\n\n// A more concise approach 👇\n// final config = RC(init: {'app.debug': true});\n\nprint(config('app.debug')); // true\n```\n\nParameters:\n\n| Name | Type | Notes |\n|----|----|----|\n| `init`| `Map\u003cString, dynamic\u003e?` | Initial collection data |\n| `loaders`| `Set\u003cLoader\u003e?` | Loader used |\n| `shouldWarn`| `bool` | Whether to allow warning information, default `true` |\n\n### Get data or collection\n\nTo get data, we use the `call` method. Usually you can ignore it. You can use the created RC instance in a similar way to function call:\n\n```dart\nfinal value = config('app.debug');\n```\n\nIt also has a type parameter `T`, which can tell the getter what data type you expect:\n\n```dart\nfinal debug = config\u003cbool\u003e('app.debug');\n```\n\n\u003e **Note**: If the `app.debug` data type is not `bool`, it will return null. If `shouldWarn` is configured as `true`, a warning message will be printed in the console.\n\nIn addition to getting specific values, you can also get collection values ​​with `Map\u003cString, dynamic\u003e` type:\n\n```dart\nfinal app = config('app'); // {debug: true}\n```\n\n### Set a value or collection\n\nSetting a value usually uses the `set` method, which can update a specific value or set a new collection:\n\n```dart\n// Sets a value\nconfig.set('app.debug', 1);\n\n// Sets a collection\nconfig.set('user.profile', {\n    'id': 1,\n    'name': 'Seven',\n});\n```\n\nCollection values ​​also support `.` connected collections, or a mixture of Map/Set/List/Iterable and `.` collections:\n\n```dart\nconfig.set('app.user', {\n    id: 1,\n    'emails.0': {id: 1, validated: true},\n    'prifile': {\n        'id': 1,\n        'posts': [\n            {id: 1, title: 'First post'},\n            {id: 2, title: 'Post 2'},\n        ],\n    },\n});\n```\n\nIn short, you can combine collection types in any way you want.\n\n### Update a value or collection\n\nUpdating a value or collection is usually a syntactic sugar for the combination of `call` and `set`, which allows you to get the previous data for processing before updating the value:\n\n```dart\nconfig.update\u003cbool\u003e('app.debug', (prev) {\nif (prev == true) return prev;\n    return false;\n});\n```\n\n### Delete a value or collection\n\nTo delete a value or collection, use the `delete` method:\n\n```dart\n// Delete a value\nconfig.delete('app.debug');\n\n// Delete colection\nconfig.delete('app');\n```\n\n### Whether contains\n\nTo determine whether a value or collection exists, you should use the `contains` method:\n\n```dart\nconfig.contains('app');\nconfig.contains('app.debug');\n```\n\n## Loaders\n\nLoaders are used to load collections from other places into RC, such as `dart --define` or environment variables.\n\nThere are two ways to configure loaders. The first is to set `loaders` when creating `RC`. You can also use `use` to configure loaders after creating an `RC` instance:\n\n```dart\nconfig.use(const DefineLoader());\n```\n\nBuilt-in loaders:\n\n| Loader | Desc |\n|----|----|\n| `DefineLoader` | KV environment variables configured using `--define` in the Dart/Flutter command line |\n| `EnvironmentLoader` | System environment variable loader, usually loads `Platform.environment` content. On platforms that do not support `dart:io`, no data will be loaded. Because there are no environment variables on platforms that do not support `dart:io`. |\n| `DotenvLoader` | Load environment variable files into collections, and load `.env` files by default. `.env` is a commonly used KV format configuration file. You can also configure the search directory, or other KV configuration files in compatible formats. |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodroe%2Frc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodroe%2Frc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodroe%2Frc/lists"}