{"id":20609514,"url":"https://github.com/fluttercommunity/redux_undo","last_synced_at":"2026-01-11T13:31:44.012Z","repository":{"id":56838050,"uuid":"225320491","full_name":"fluttercommunity/redux_undo","owner":"fluttercommunity","description":"Redux Undo - Make your redux store undo- and redoable. Inspired by the JS redux_undo package. Maintainer: @michelengelen","archived":false,"fork":false,"pushed_at":"2020-04-23T14:29:29.000Z","size":158,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T15:51:59.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/redux_undo","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/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-12-02T08:13:20.000Z","updated_at":"2024-03-26T20:08:22.000Z","dependencies_parsed_at":"2022-09-13T04:54:31.295Z","dependency_job_id":null,"html_url":"https://github.com/fluttercommunity/redux_undo","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/fluttercommunity%2Fredux_undo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fredux_undo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fredux_undo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercommunity%2Fredux_undo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluttercommunity","download_url":"https://codeload.github.com/fluttercommunity/redux_undo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249006376,"owners_count":21197262,"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-11-16T10:13:47.268Z","updated_at":"2026-01-11T13:31:44.007Z","avatar_url":"https://github.com/fluttercommunity.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Flutter Community: redux_undo](https://fluttercommunity.dev/_github/header/redux_undo)](https://github.com/fluttercommunity/community)\n\n[![Build Status](https://travis-ci.com/fluttercommunity/redux_undo.svg?branch=master)](https://travis-ci.com/fluttercommunity/redux_undo)\n[![codecov](https://codecov.io/gh/fluttercommunity/redux_undo/branch/master/graph/badge.svg)](https://codecov.io/gh/fluttercommunity/redux_undo)\n[![pub package](https://img.shields.io/pub/v/redux_undo.svg)](https://pub.dartlang.org/packages/redux_undo)\n\n# redux_undo.dart\n\nThis package will make your redux store undoable.\n\n## Things to come in the future\n- [ ] Support for making only a slice of the state undoable\n- [ ] more examples and documentation\n\n## Installation\n\ndefine the dependency in your `pubspec.yaml` file:\n```yaml\ndependencies:\n  redux_undo: ^1.0.0+1\n```\n\nupdate your applications packages by running\n```shell\npub get\n```\n\nor when using flutter as a framework\n```shell\nflutter pub get\n```\n\nimport the package to use in the file you are setting up redux:\n```dart\nimport 'package:redux_undo/redux_undo.dart';\n```\n\n## Structure\n\n`redux_undo` will slightly modify your state by adding a new properties-layer at the root of the store. The final structure will look like this:\n```dart\n/// when accessed directly from the store, store.state will have this structure\nUndoableHistory\u003cS\u003e state = {\n  past: \u003cS\u003e[],\n  present: null, // \u003c-- the current state of the app\n  future: \u003cS\u003e[],\n  latestUnfiltered: null // \u003c-- basically equals present, to store a mutual state before storing it into past or future \n};\n```\n\n## Usage\n\nBecause it modifies the initial state you need to initiate `redux_undo` when initiating the redux store.\nThis is done by calling 2 separate functions:\n\n```dart\n/// to wrap the root reducer\nReducer\u003cUndoableState\u003cS\u003e\u003e createUndoableReducer\u003cS\u003e(Reducer\u003cS\u003e reducer, { UndoableConfig config });\n\n/// to wrap the Root state of your app.\nUndoableState\u003cS\u003e createUndoableState\u003cS\u003e(S initialState, bool ignoreInitialState);\n```\n\nHere is an example of how this can be done in a flutter app:\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:flutter_redux/flutter_redux.dart';\nimport 'package:redux/redux.dart';\nimport 'package:redux_undo/redux_undo.dart';\n\nvoid main() =\u003e runApp(MyApp());\n\nclass MyApp extends StatelessWidget {\n\n  final Store\u003cUndoableState\u003cRootState\u003e\u003e store = Store\u003cUndoableState\u003cRootState\u003e\u003e(\n    createUndoableReducer\u003cRootState\u003e(rootReducer),\n    initialState: createUndoableState(RootState.initial(), false),\n  );\n\n  @override\n  Widget build(BuildContext context) {\n    return StoreProvider\u003cUndoableState\u003cRootState\u003e\u003e(\n      store: store,\n      child: MaterialApp(\n        title: 'Redux Undo Demo',\n        home: const MyHomePage(),\n      ),\n    );\n  }\n}\n```\n\n## Actions\n\n`redux_undo` provides 4 basic actions\n\n- `UndoableUndoAction` - Standard-Action for undo\n    \n    **Usage:** `store.dispatch(UndoableUndoAction())`\n- `UndoableRedoAction` - Standard-Action for redo\n    \n    **Usage:** `store.dispatch(UndoableRedoAction())`\n- `UndoableJumpAction` - Standard-Action for jump (to past or to future)\n    \n    **Usage:** `store.dispatch(UndoableJumpAction(index: -2))` // \u003c- jumps 2 steps to the past (same as dispatching `UndoableUndoAction` twice)\n    \n    **Usage:** `store.dispatch(UndoableJumpAction(index: 0))` // \u003c- does nothing, since it just returns the current `UndoableState`\n    \n    **Usage:** `store.dispatch(UndoableJumpAction(index: 2))` // \u003c- jumps 2 steps to the future (same as dispatching `UndoableRedoAction` twice)\n\n- `UndoableClearHistoryAction` - Standard-Action for clearing the history\n\n## Options\n\nIt is possible to provide a configuration object to the UndoableState instantiation like this:\n```dart\nfinal UndoableConfig config = UndoableConfig(\n  limit: 100,\n  blackList: \u003cType\u003e[\n    BlacklistedAction,\n  ],\n  whiteList: \u003cType\u003e[\n    WhitelistedAction,\n  ],\n);\n```\n\nThen pass it to the `createUndoableReducer` function like this:\n```dart\nfinal Store\u003cUndoableState\u003cRootState\u003e\u003e store = Store\u003cUndoableState\u003cRootState\u003e\u003e(\n    createUndoableReducer\u003cRootState\u003e(rootReducer, config: config),\n    initialState: createUndoableState(RootState.initial(), false),\n);\n```\nThese are the options the `UndoableConfig` class provides:\n- int limit: limits the length of the `UndoableState.past` List and with this ultimately the length of `UndoableState.future` as well\n    - default value =\u003e **10**\n- List\u003cType\u003e whiteList: actions in this list need to be extended from one of the provided `redux_undo` actions and will fire the original `rootReducer` after performing the action they extended from without updating `UndoableState.past` or `UndoableState.future`  \n\n## Contributors\n\n  * [Michel Engelen](https://github.com/michelengelen)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercommunity%2Fredux_undo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluttercommunity%2Fredux_undo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercommunity%2Fredux_undo/lists"}