{"id":18632911,"url":"https://github.com/esenmx/collection_notifiers","last_synced_at":"2025-11-04T07:30:32.411Z","repository":{"id":43048819,"uuid":"451225778","full_name":"esenmx/collection_notifiers","owner":"esenmx","description":"Collections with implementation of ValueListenable/ChangeNotifier for minimum rebuild and simplest syntax","archived":false,"fork":false,"pushed_at":"2023-09-28T12:52:30.000Z","size":260,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T18:38:04.490Z","etag":null,"topics":["collection","dart","data-structures","flutter","performance-optimization","state-management"],"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/esenmx.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-01-23T20:42:51.000Z","updated_at":"2024-05-10T03:59:05.000Z","dependencies_parsed_at":"2024-08-22T23:07:01.492Z","dependency_job_id":null,"html_url":"https://github.com/esenmx/collection_notifiers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esenmx%2Fcollection_notifiers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esenmx%2Fcollection_notifiers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esenmx%2Fcollection_notifiers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esenmx%2Fcollection_notifiers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esenmx","download_url":"https://codeload.github.com/esenmx/collection_notifiers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239427966,"owners_count":19636860,"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":["collection","dart","data-structures","flutter","performance-optimization","state-management"],"created_at":"2024-11-07T05:13:40.841Z","updated_at":"2025-11-04T07:30:32.381Z","avatar_url":"https://github.com/esenmx.png","language":"Dart","readme":"# collection_notifiers\n\n\u003ca href=\"https://pub.dev/packages/collection_notifiers\"\u003e\u003cimg src=\"https://img.shields.io/pub/v/collection_notifiers.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/esenmx/collection_notifiers/actions\"\u003e\u003cimg src=\"https://github.com/esenmx/collection_notifiers/workflows/Build/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/esenmx/collection_notifiers\"\u003e\u003cimg src=\"https://codecov.io/gh/esenmx/collection_notifiers/branch/master/graph/badge.svg\" alt=\"codecov\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/esenmx/collection_notifiers\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/esenmx/collection_notifiers.svg?style=flat\u0026logo=github\u0026colorB=deeppink\u0026label=stars\" alt=\"Star on Github\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-purple.svg\" alt=\"License: MIT\"\u003e\u003c/a\u003e\n\nWrapped [collections][collections] with [ChangeNotifier][ChangeNotifier] \u0026 [ValueListenable][ValueListenable]\ninterface for optimized rebuilds and better syntax.\n\n## Features\n\n- Huge performance benefits for medium/large collections\n\n- Best possible syntax, minimum amount of code\n\n- Fully compatible with [ValueListenableBuilder][ValueListenableBuilder] and [Riverpod][Riverpod] / [Provider][Provider]\n\n- Dead simple to use\n\n### Riverpod/Provider without `collection_notifiers`\n\n- Always `triggers setState`\n- Always `creates copies`\n- `Verbose` syntax\n\n```dart\nfinal setProvider = StateProvider((ref) =\u003e \u003cE\u003e{});\n```\n\n```dart\nonAdd: (value) =\u003e ref.read(setProvider.state).update((state) {\n  return \u003cE\u003e{...state, value}; // a new copy created\n});\nonRemove: (value) =\u003e ref.read(setProvider.state).update((state) {\n  return \u003cE\u003e{...state..remove(value)}; // a new copy created\n});\n```\n\n### Riverpod/Provider with `collection_notifiers`\n\n- Triggers `setState only when needed`\n- Creates `zero copy`\n- `Terse` syntax\n\n```dart\nfinal setProvider = ChangeNotifierProvider((ref) =\u003e SetNotifier\u003cE\u003e());\n```\n\n```dart\nonAdd: ref.read(setProvider).add; // does not create copy\nonRemove: ref.read(setProvider).remove; // does not create copy\n```\n\nOperators are also overridden, `List`:\n\n```dart\nfinal listProvider = ChangeNotifierProvider((ref) =\u003e ListNotifier([0]));\nref.read(listProvider)[0] = 1; // will trigger setState\nref.read(listProvider)[0] = 1; // won't trigger setState\n```\n\nSimilarly, the `Map`:\n\n```dart\nfinal mapProvider = ChangeNotifierProvider((ref) =\u003e MapNotifier());\nref.read(mapProvider)['a'] = 1; // will trigger setState\nref.read(mapProvider)['a'] = 1; // won't trigger setState\n```\n\n## Implementations\n\n| Collection |               Status               |   Notifier    |\n|------------|:----------------------------------:|:-------------:|\n| Set        |           **Completed**            |  SetNotifier  |  \n| List       |     **Completed**(_see notes_)     | ListNotifier  |\n| Map        |           **Completed**            |  MapNotifier  |\n| Queue      |           **Completed**            | QueueNotifier |\n\n_Open an issue if there is any specific collection/method you need._\n\n## Element Equality\n\nElement equation([== operator](https://api.dart.dev/stable/2.13.4/dart-core/Object/operator_equals.html)) must be\nhandled by you beforehand. For that case, code generation([freezed][freezed], [built_value][built_value] etc.) or\n[equatable][equatable] are highly recommended.\n\n## Notes\n\n- `collection_notifiers` do not handle any `Exception` because it may cause confusing development experience and sneaky\n  bugs.\n\n- Methods with overridden logic, always mimics default implementation. Hence, no additional `Exception` is\n  also produced.\n  \n- Methods that requires collection equalities(like `sort()`, `shuffle()` etc...) always trigger setState.\n\n[//]: # (Links)\n\n[collections]: https://api.dart.dev/stable/dart-collection/dart-collection-library.html\n[ChangeNotifier]: https://api.flutter.dev/flutter/foundation/ChangeNotifier-class.html\n[ValueListenable]: https://api.flutter.dev/flutter/foundation/ValueListenable-class.html\n[ValueListenableBuilder]: https://api.flutter.dev/flutter/widgets/ValueListenableBuilder-class.html\n[Riverpod]: https://pub.dev/documentation/flutter_riverpod/latest/flutter_riverpod/ChangeNotifierProvider-class.html\n[Provider]: https://pub.dev/documentation/provider/latest/provider/ChangeNotifierProvider-class.html\n[freezed]: https://pub.dev/packages/freezed\n[built_value]: https://pub.dev/packages/built_value\n[equatable]: https://pub.dev/packages/equatable\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesenmx%2Fcollection_notifiers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesenmx%2Fcollection_notifiers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesenmx%2Fcollection_notifiers/lists"}