{"id":20609513,"url":"https://github.com/fluttercommunity/state_persistence","last_synced_at":"2025-04-15T04:31:00.446Z","repository":{"id":56840477,"uuid":"179590697","full_name":"fluttercommunity/state_persistence","owner":"fluttercommunity","description":"State Persistence - Persist state across app launches. By default this library store   state as a local JSON file called `data.json` in the applications   data directory. Maintainer: @slightfoot","archived":false,"fork":false,"pushed_at":"2021-08-26T07:42:03.000Z","size":83,"stargazers_count":74,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T15:51:58.541Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/state_persistence","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/fluttercommunity.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}},"created_at":"2019-04-04T23:16:20.000Z","updated_at":"2024-07-20T04:50:18.000Z","dependencies_parsed_at":"2022-08-29T01:51:16.159Z","dependency_job_id":null,"html_url":"https://github.com/fluttercommunity/state_persistence","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fstate_persistence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fstate_persistence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fstate_persistence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fstate_persistence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluttercommunity","download_url":"https://codeload.github.com/fluttercommunity/state_persistence/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249006367,"owners_count":21197260,"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":["hacktoberfest"],"created_at":"2024-11-16T10:13:47.034Z","updated_at":"2025-04-15T04:31:00.421Z","avatar_url":"https://github.com/fluttercommunity.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Flutter Community: state_persistence](https://fluttercommunity.dev/_github/header/state_persistence)](https://github.com/fluttercommunity/community)\n\n# State Persistence\n\n[![pub package](https://img.shields.io/pub/v/state_persistence.svg)](https://pub.dartlang.org/packages/state_persistence)\n\nPersist state across app launches. By default this library store \nstate as a local JSON file called `data.json` in the applications\ndata directory. You can change this filename by providing another\nstorage mechanism.\n\nIf you do not want to store your persisted app state as a JSON \nfile you can extend `PersistedStateStorage` and provide your own \nmethods for saving and loading data. E.g `shared_preferences` or \n`sqflite`. For those of you that are ambitious you could even \nstore your state on the web or even in Firebase.\n\nTo change the persisted state simply modify the values in the \ndata map. These changes will automatically be persisted to disk\nbased on the `saveTimeout` given to the `PersistedAppState` widget.\nBy default this value is `500` milliseconds. This timeout is used\nto stop disk thrashing on multiple map changes in quick succession.  \n\n### Example\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:state_persistence/state_persistence.dart';\n\nvoid main() =\u003e runApp(App());\n\nclass App extends StatefulWidget {\n  @override\n  _AppState createState() =\u003e _AppState();\n}\n\nclass _AppState extends State\u003cApp\u003e {\n  TextEditingController _textController;\n\n  @override\n  Widget build(BuildContext context) {\n    return PersistedAppState(\n      storage: JsonFileStorage(),\n      child: MaterialApp(\n        title: 'Persistent TextField Example',\n        theme: ThemeData(primarySwatch: Colors.indigo),\n        home: Scaffold(\n          appBar: AppBar(title: Text('Persistent TextField Example')),\n          body: Container(\n            padding: const EdgeInsets.all(32.0),\n            alignment: Alignment.center,\n            child: PersistedStateBuilder(\n              builder: (BuildContext context, AsyncSnapshot\u003cPersistedData\u003e snapshot) {\n                if (snapshot.hasData) {\n                  if (_textController == null) {\n                    _textController = TextEditingController(text: snapshot.data['text'] ?? '');\n                  }\n                  return TextField(\n                    controller: _textController,\n                    decoration: InputDecoration(\n                      hintText: 'Enter some text',\n                    ),\n                    onChanged: (String value) =\u003e snapshot.data['text'] = value,\n                  );\n                } else {\n                  return CircularProgressIndicator();\n                }\n              },\n            ),\n          ),\n        ),\n      ),\n    );\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercommunity%2Fstate_persistence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluttercommunity%2Fstate_persistence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercommunity%2Fstate_persistence/lists"}