{"id":15489152,"url":"https://github.com/roughike/multiplatform_key_value_store","last_synced_at":"2025-04-22T18:18:57.433Z","repository":{"id":56833506,"uuid":"152059982","full_name":"roughike/multiplatform_key_value_store","owner":"roughike","description":null,"archived":false,"fork":false,"pushed_at":"2019-11-13T08:46:58.000Z","size":44,"stargazers_count":29,"open_issues_count":7,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T16:21:53.854Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roughike.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-10-08T10:15:49.000Z","updated_at":"2023-06-30T20:36:42.000Z","dependencies_parsed_at":"2022-09-08T07:41:46.206Z","dependency_job_id":null,"html_url":"https://github.com/roughike/multiplatform_key_value_store","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fmultiplatform_key_value_store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fmultiplatform_key_value_store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fmultiplatform_key_value_store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fmultiplatform_key_value_store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roughike","download_url":"https://codeload.github.com/roughike/multiplatform_key_value_store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250296286,"owners_count":21407037,"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":[],"created_at":"2024-10-02T07:04:08.149Z","updated_at":"2025-04-22T18:18:57.373Z","avatar_url":"https://github.com/roughike.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Key-value store for multiplatform Dart projects\n\n\u003e What the heck is that?\n\nGlad you asked! \u003csub\u003e\u003csup\u003e(docs are work in progress, but the libraries are stable.)\u003c/sup\u003e\u003c/sub\u003e\n\nMultiplatform key-value store is like any other key value store, but it's _multiplatform_. Badum-tss!\n\n# Package overview\n\nThis repo contains three different folders. Each of them is a Dart package project.\n\n## key_value_store [![pub package](https://img.shields.io/pub/v/key_value_store.svg)](https://pub.dartlang.org/packages/key_value_store)\n\nThe `key_value_store` package defines common key-value storage APIs in an abstract way without caring about the implementation.\n\nYou might ask what is the point for this, and that is an entirely valid question!\nWhen you're doing code sharing across Flutter and the web, you can't import platform specific dependencies in your core business logic components.\nUsing `localStorage` for web or `SharedPreferences` for Flutter in your pure business logic is a no-no.\n\nHere's how you would use the abstract class in your common business logic:\n\n```dart\nimport 'package:key_value_store/key_value_store.dart';\n\nclass MyBusinessLogic {\n  MyBusinessLogic(this.kvs);\n  final KeyValueStore kvs;\n  \n  void storeHelloMessage(String name) {\n    final result = 1 + 2; // Real world is more complicated - this is just a sample.\n    kvs.setString('message', 'Hello, $name! Did you know that 1 + 2 is $result?');\n  }\n}\n```\n\n## key_value_store_flutter [![pub package](https://img.shields.io/pub/v/key_value_store_flutter.svg)](https://pub.dartlang.org/packages/key_value_store_flutter)\n\nThis implements the abstract class defined in `key_value_store` with Flutter-specific implementation. \nIn this case, using `SharedPreferences`. \n\nTo use, pass it `SharedPreferences` from the [shared_preferences](https://pub.dartlang.org/packages/shared_preferences) Flutter plugin package:\n\n```dart\nimport 'package:key_value_store_flutter/key_value_store_flutter.dart';\nimport 'package:shared_preferences/shared_preferences.dart';\n\nfinal prefs = await SharedPreferences.getInstance();\nfinal kvs = FlutterKeyValueStore(prefs);\n\n...\n// Pass the Flutter specific key-value store to MyBusinessLogic!\nfinal myBusinessLogic = MyBusinessLogic(kvs);\n```\n\n## key_value_store_web [![pub package](https://img.shields.io/pub/v/key_value_store_web.svg)](https://pub.dartlang.org/packages/key_value_store_web)\n\nThis is also an implementation of the interface defined in the `key_value_store` package.\nPass it `window.localStorage` or `window.sessionStorage` from the `dart:html` package and you're good to go:\n\n```dart\nimport 'package:key_value_store_web/key_value_store_web.dart';\nimport 'dart:html';\n\nfinal kvs = WebKeyValueStore(window.localStorage);\n\n...\n// Pass the web specific key-value store to MyBusinessLogic!\nfinal myBusinessLogic = MyBusinessLogic(kvs);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froughike%2Fmultiplatform_key_value_store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froughike%2Fmultiplatform_key_value_store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froughike%2Fmultiplatform_key_value_store/lists"}