{"id":32275192,"url":"https://github.com/t0uh33d/get_cubit","last_synced_at":"2026-02-22T03:40:30.713Z","repository":{"id":63199825,"uuid":"565954338","full_name":"t0uh33d/get_cubit","owner":"t0uh33d","description":"\"GetCubit\" is a package for managing Cubit instances in a Flutter app. It allows for easy registration, access, and deletion of singleton or multiple Cubit instances with unique identifiers, and facilitates communication between instances. Simple installation and usage.","archived":false,"fork":false,"pushed_at":"2024-03-12T11:24:19.000Z","size":301,"stargazers_count":2,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T23:45:24.094Z","etag":null,"topics":["code-management","dependency-injection","flutter-cubit","flutter-widget","mobile-application-development","optimization-algorithms","singleton-pattern","state-management"],"latest_commit_sha":null,"homepage":"https://medium.com/@touheed/mastering-bloc-with-getcubit-in-flutter-5a475d05caf6","language":"C++","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/t0uh33d.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}},"created_at":"2022-11-14T17:11:41.000Z","updated_at":"2025-02-24T10:51:57.000Z","dependencies_parsed_at":"2024-03-12T12:41:58.195Z","dependency_job_id":"0cf2173b-5996-4d25-a4c7-bb4cd259979e","html_url":"https://github.com/t0uh33d/get_cubit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/t0uh33d/get_cubit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0uh33d%2Fget_cubit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0uh33d%2Fget_cubit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0uh33d%2Fget_cubit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0uh33d%2Fget_cubit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t0uh33d","download_url":"https://codeload.github.com/t0uh33d/get_cubit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0uh33d%2Fget_cubit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29704418,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T03:17:42.375Z","status":"ssl_error","status_checked_at":"2026-02-22T03:17:31.622Z","response_time":110,"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":["code-management","dependency-injection","flutter-cubit","flutter-widget","mobile-application-development","optimization-algorithms","singleton-pattern","state-management"],"created_at":"2025-10-22T23:44:57.749Z","updated_at":"2026-02-22T03:40:30.706Z","avatar_url":"https://github.com/t0uh33d.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Get Cubit\n\nThe GetCubit package provides a way to manage instances of the Cubit class in a Dart/Flutter application. The Cubit class is a state management pattern used in the Flutter framework, which allows for the separation of state management from the widgets that use that state. By using the GetCubit package, developers can register a singleton or multiple instances of the Cubit class using unique identifiers. This allows for easy access and manipulation of the state across the entire application.\n\nThe package includes several methods for managing these instances:\n\n- `put`: This method is used to register an instance of the Cubit class. It takes in a Cubit instance and an optional id parameter, which can be used to create multiple unique instances of the same Cubit class. The method returns the registered instance of the Cubit class.\n\n- `find`: This method is used to retrieve a registered instance of the Cubit class. It takes in the Cubit class type and an optional id parameter, and returns the corresponding instance. If the instance is not found, it throws an error.\n\n- `delete`: This method is used to delete a registered instance of the Cubit class. It takes in the Cubit class type and an optional id parameter, and removes the corresponding instance from the internal map.\n\n- `deleteAllCubitInstances`: This method is used to delete all registered instances of a Cubit class. It takes in the Cubit class type, and removes all instances of that class from the internal map.\n\n- `flush`: This method is used to delete all registered instances of Cubit class, with the option to exclude certain instances from being deleted.\n\n- `getAllInstanceIds`: This method is used to list all unique identifiers linked to instances of a cubit class.\n\nIt also provides functionality for cubit-to-cubit communication, and listing all the unique identifiers linked to instances of a cubit.\n\nIn order to use this package, it needs to be added as a dependency in the pubspec.yaml file of the flutter project, and then imported in the dart file where it is being used. Once imported, it can be used to register and manage instances of the Cubit class throughout the application.\n\nIt can be used to create a singleton instance of a cubit, which means that the same instance will be shared across the entire application, or it can be used to create multiple instances of the same cubit class, each with a unique identifier. It also provides an easy way to delete instances of the Cubit class when they are no longer needed.\n\nOverall, the GetCubit package provides a useful way to manage instances of the Cubit class in a Dart/Flutter application, making it easier to separate state management from the widgets that use that state, and allowing for easy access and manipulation of that state throughout the entire application.\n\n# Installation\n\nTo use this package, add `get_cubit` to your pubsec.yaml file.\n\nor run the below command\n\n```dart\npub add get_cubit\n```\n\n# Usage\n\nexample of cubit :\n\n```dart\nclass CounterCubit extends Cubit\u003cint\u003e {\n  CounterCubit() : super(0);\n\n  void increment() =\u003e emit(state + 1);\n  void decrement() =\u003e emit(state - 1);\n}\n```\n\n### Registering a cubit instance\n\nTo register an instance of the `CounterCubit` class\n\n```dart\n// register a new instance\nGetCubit.put(CounterCubit());\n\n// register an existing instance\nCounterCubit counterCubit = CounterCubit();\nGetCubit.put(counterCubit);\n\n// another way to register an existing instance\ncounterCubit.addInstanceToGetCubit\u003cCounterCubit\u003e();\n```\n\n### Creating multiple instances using unique identifiers\n\n```dart\n// register a new instance with id\nGetCubit.put(CounterCubit(), id : \"cubit_1\");\nGetCubit.put(CounterCubit(), id : \"cubit_2\");\n\n// register an existing instance with id\nCounterCubit counterCubit1 = CounterCubit();\nCounterCubit counterCubit2 = CounterCubit();\nGetCubit.put(counterCubit1, id : \"cubit_1\");\nGetCubit.put(counterCubit1, id : \"cubit_2\");\n\n// another way to register an existing instance with id\ncounterCubit1.addInstanceToGetCubit\u003cCounterCubit\u003e(id : \"cubit_1\");\ncounterCubit2.addInstanceToGetCubit\u003cCounterCubit\u003e(id : \"cubit_2\");\n```\n\n### Accessing the registered instances\n\nThe registered instances can be accessed using `GetCubit.find()`\n\n```dart\n// file_1.dart :\nfinal CounterCubit counterCubit = GetCubit.put(CounterCubit());\nprint(counterCubit.state); // 0\ncounterCubit.increment();\n\n// file_2.dart\nprint(GetCubit.find\u003cCounterCubit\u003e().state); // 1\n```\n\n### Accessing the registered instances using id\n\n```dart\n// file_1.dart :\nfinal CounterCubit counterCubit1 = GetCubit.put(CounterCubit(), id : \"cubit_1\");\nfinal CounterCubit counterCubit2 = GetCubit.put(CounterCubit(), id : \"cubit_2\");\ncounterCubit1.emit(5);\ncounterCubit2.emit(10);\n\n// file_2.dart\nprint(GetCubit.find\u003cCounterCubit\u003e(id : \"cubit_1\").state); // 5\nprint(GetCubit.find\u003cCounterCubit\u003e(id : \"cubit_2\").state); // 10\n```\n\n### deleting a registered instance\n\n```dart\n GetCubit.delete\u003cCounterCubit\u003e(); // without id\n GetCubit.delete\u003cCounterCubit\u003e(id : \"cubit_1\"); // with id\n```\n\n### deleting all the registered instances linked of a cubit\n\n```dart\nGetCubit.find\u003cCounterCubit\u003e().deleteAllInstances();\n```\n\n### Listing all the unique ids linked to instances of a cubit\n\n```dart\nGetCubit.put(CounterCubit(),id : \"c1\");\nGetCubit.put(CounterCubit(),id : \"c2\");\nGetCubit.put(CounterCubit(),id : \"c3\");\nGetCubit.put(CounterCubit(),id : \"c4\");\nGetCubit.put(CounterCubit(),id : \"c5\");\n\nList\u003cString\u003e ids = GetCubit.find\u003cCounterCubit\u003e().getAllInstanceIds();\nprint(ids); // [c1,c2,c3,c4,c5]\n```\n\n### Clear all instances of cubit from memory\n\n```dart\nGetCubit.flush();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft0uh33d%2Fget_cubit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft0uh33d%2Fget_cubit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft0uh33d%2Fget_cubit/lists"}