{"id":31228950,"url":"https://github.com/stephane-archer/flutter_persistent_string_set","last_synced_at":"2025-09-23T08:46:36.202Z","repository":{"id":315526051,"uuid":"1058318845","full_name":"stephane-archer/flutter_persistent_string_set","owner":"stephane-archer","description":"A simple Dart package that provides a Set\u003cString\u003e like interface which is persisted on the device.","archived":false,"fork":false,"pushed_at":"2025-09-16T23:54:26.000Z","size":6,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-19T06:20:27.428Z","etag":null,"topics":["dart-library","dart-package","flutter","flutter-settings"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/persistent_string_set","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/stephane-archer.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-16T23:52:34.000Z","updated_at":"2025-09-17T03:24:28.000Z","dependencies_parsed_at":"2025-09-19T06:20:34.672Z","dependency_job_id":"5c7e3851-0b1a-4a9e-aeb2-d567dd611ffa","html_url":"https://github.com/stephane-archer/flutter_persistent_string_set","commit_stats":null,"previous_names":["stephane-archer/flutter_persistent_string_set"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stephane-archer/flutter_persistent_string_set","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-archer%2Fflutter_persistent_string_set","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-archer%2Fflutter_persistent_string_set/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-archer%2Fflutter_persistent_string_set/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-archer%2Fflutter_persistent_string_set/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephane-archer","download_url":"https://codeload.github.com/stephane-archer/flutter_persistent_string_set/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephane-archer%2Fflutter_persistent_string_set/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276368094,"owners_count":25629970,"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-09-22T02:00:08.972Z","response_time":79,"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":["dart-library","dart-package","flutter","flutter-settings"],"created_at":"2025-09-22T07:46:02.261Z","updated_at":"2025-09-22T07:46:07.144Z","avatar_url":"https://github.com/stephane-archer.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Persistent String Set\n\nA simple Dart package that provides a `Set\u003cString\u003e` like interface which is persisted on the device. This is useful for managing a collection of unique strings that need to be saved across app launches, such as user favorites or tags.\n\n## Features\n\n- Provides a `Set`-like API for managing a collection of strings.\n- Automatically persists changes to device storage.\n- Simple and easy to use.\n\n## Getting started\n\nAdd the package to your `pubspec.yaml`:\n\n```bash\nflutter pub add persistent_string_set\n```\n\nOr add it manually:\n\n```yaml\ndependencies:\n  persistent_string_set: ^latest_version # Replace with the latest version\n```\n\n## Usage\n\nHere's an example of how you might use `PersistentStringSet` to manage a user's favorite items in an application. You can wrap it in a service class for easy management.\n\n```dart\nimport 'package:persistent_string_set/persistent_string_set.dart';\n\n/// A service to manage user's favorite items.\nclass FavoritesService {\n  late final PersistentStringSet _favorites;\n  bool _isInitialized = false;\n\n  // A unique key to store the favorites in persistent storage.\n  static const _favoritesKey = 'user_favorites';\n\n  /// Initializes the service by loading the favorites from storage.\n  Future\u003cvoid\u003e initialize() async {\n    if (_isInitialized) return;\n    _favorites = await PersistentStringSet.create(_favoritesKey);\n    _isInitialized = true;\n  }\n\n  /// Adds an item to the user's favorites.\n  Future\u003cvoid\u003e addFavorite(String itemId) async {\n    await _favorites.add(itemId);\n  }\n\n  /// Removes an item from the user's favorites.\n  Future\u003cvoid\u003e removeFavorite(String itemId) async {\n    await _favorites.remove(itemId);\n  }\n\n  /// Checks if an item is in the user's favorites.\n  bool isFavorite(String itemId) {\n    // Throws if the service is not initialized.\n    return _favorites.contains(itemId);\n  }\n\n  /// Returns a copy of all favorite items.\n  Set\u003cString\u003e getFavorites() {\n    return _favorites.toSet();\n  }\n  \n  /// Returns the number of favorite items.\n  int get favoritesCount =\u003e _favorites.length;\n}\n\n// Example of how to use the service\nvoid main() async {\n  // You would typically initialize your services once when the app starts.\n  final favoritesService = FavoritesService();\n  await favoritesService.initialize();\n\n  // Now you can use the service to manage favorites across your app.\n  print('Adding item_123 to favorites...');\n  await favoritesService.addFavorite('item_123');\n  print('Is item_123 a favorite? ${favoritesService.isFavorite('item_123')}'); // true\n  print('Total favorites: ${favoritesService.favoritesCount}'); // 1\n\n  print('Adding item_456 to favorites...');\n  await favoritesService.addFavorite('item_456');\n  print('Total favorites: ${favoritesService.favoritesCount}'); // 2\n\n  // The data persists. If you restart the app and initialize the service again,\n  // the favorites will still be there.\n\n  print('Removing item_123 from favorites...');\n  await favoritesService.removeFavorite('item_123');\n  print('Is item_123 a favorite? ${favoritesService.isFavorite('item_123')}'); // false\n  print('Total favorites: ${favoritesService.favoritesCount}'); // 1\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephane-archer%2Fflutter_persistent_string_set","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephane-archer%2Fflutter_persistent_string_set","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephane-archer%2Fflutter_persistent_string_set/lists"}