{"id":17645819,"url":"https://github.com/masreplay/riverpod_cache","last_synced_at":"2025-06-13T20:35:18.647Z","repository":{"id":248348426,"uuid":"828447633","full_name":"masreplay/riverpod_cache","owner":"masreplay","description":"Add offline persistence support for Riverpod","archived":false,"fork":false,"pushed_at":"2024-08-23T14:25:15.000Z","size":331,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T04:11:57.877Z","etag":null,"topics":["cahce","dart","flutter","offline","riverpod"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/riverpod_cache","language":"C++","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/masreplay.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":"2024-07-14T07:15:48.000Z","updated_at":"2025-01-14T18:41:32.000Z","dependencies_parsed_at":"2024-10-23T14:02:22.205Z","dependency_job_id":null,"html_url":"https://github.com/masreplay/riverpod_cache","commit_stats":null,"previous_names":["masreplay/riverpod_cache"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/masreplay/riverpod_cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masreplay%2Friverpod_cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masreplay%2Friverpod_cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masreplay%2Friverpod_cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masreplay%2Friverpod_cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masreplay","download_url":"https://codeload.github.com/masreplay/riverpod_cache/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masreplay%2Friverpod_cache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259716404,"owners_count":22900868,"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":["cahce","dart","flutter","offline","riverpod"],"created_at":"2024-10-23T10:59:41.622Z","updated_at":"2025-06-13T20:35:18.628Z","avatar_url":"https://github.com/masreplay.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Riverpod offline persistence\n\n[![Pub](https://img.shields.io/pub/v/riverpod_cache.svg)](https://pub.dev/packages/riverpod_cache)\n[![GitHub stars](https://img.shields.io/github/stars/masreplay/riverpod_cache.svg?style=social)](https://github.com/masreplay/riverpod_cache)\n\nAdd offline persistence support for Riverpod providers\n\n## inspiration\nFix Riverpod issue of cache and offline persistence  https://github.com/rrousselGit/riverpod/issues/1032\n\n## Features\n- [x] Cache `FutureProvider` \n- [x] Cache `StreamProvider` \n- [x] Cache `StateNotifierProvider`\n- [x] Cache `StateProvider`\n- [x] And more...\n\n## Getting Started\n\nIn order to use this package, you need to add `riverpod_cache` as a dependency in your `pubspec.yaml` file.\n\n```yaml\ndependencies:\n  riverpod_cache: ^0.0.2\n```\n\nThen, run `flutter pub get` to fetch the package.\n\n## Usage\n\n```dart\nimport 'package:riverpod_cache/riverpod_cache.dart';\n\n@riverpod\nSharedPreferences sharedPreferences(SharedPreferencesRef ref) {\n  throw UnimplementedError();\n}\n\n@riverpod\nStream\u003cTodoResponse\u003e todo(TodoRef ref) {\n  return ref.cacheFirstOfflinePersistence(\n    key: 'todo',\n    future: () async {\n      await Future.delayed(const Duration(seconds: 2));\n      final response = await Dio().get(\n        'https://jsonplaceholder.typicode.com/todos/1',\n      );\n\n      final result = TodoResponse.fromJson(response.data);\n\n      return result;\n    },\n    sharedPreferences: ref.read(sharedPreferencesProvider),\n    fromJson: TodoResponse.fromJson,\n    toJson: (object) =\u003e object.toJson(),\n  );\n}\n\nFuture\u003cvoid\u003e main() async {\n  WidgetsFlutterBinding.ensureInitialized();\n  final sharedPreferences = await SharedPreferences.getInstance();\n  runApp(\n    ProviderScope(\n      overrides: [\n        sharedPreferencesProvider.overrideWithValue(sharedPreferences),\n      ],\n      child: const MainApp(),\n    ),\n  );\n}\n```\n## Documentation\n\nFor more details, check out the [documentation](https://pub.dev/documentation/riverpod_cache/latest/).\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions, please create a new issue or submit a pull request.\n\n## License\n\nThis project is licensed under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasreplay%2Friverpod_cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasreplay%2Friverpod_cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasreplay%2Friverpod_cache/lists"}