redux_undo 0.1.0+4

  • Readme
  • Changelog
  • Installing
  • 50

redux_undo.dart #

This package will make your redux store undoable.



The package as it is now is still in Beta phase. So you are free to use it as is, but please keep in mind that, until version 1.0.0 is released all class, function and helper-names are prone to change.

Installation #

define the dependency in your pubspec.yaml file:

  redux_undo: ^0.1.0+4

update your applications packages by running

pub get

or when using flutter as a framework

flutter pub get

import the package to use in the file you are setting up redux:

import 'package:redux_undo/redux_undo.dart';

Structure #

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:

/// when accessed directly from the store, store.state will have this structure
UndoableHistory state = {
  past: <dynamic>[],
  present: null, // <-- the current state of the app
  future: <dynamic>[],
  latestUnfiltered: null// <-- basically equals present, to store a mutual state before storing it into past or future 

Usage #

Because it modifies the initial state you need to initiate redux_undo when initiating the redux store. This is done by calling 2 separate functions:

/// to wrap the root reducer
Reducer<UndoableState> createUndoableReducer(Function<Reducer> reducer);

/// to wrap the Root state of your app.
UndoableState createUndoableState(dynamic state);

Here is an example of how this can be done in a flutter app:

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';
import 'package:redux_undo/redux_undo.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {

  final Store<UndoableState> store = Store<UndoableState>(
    initialState: createUndoableState(RootState.initial()),

  Widget build(BuildContext context) {
    return StoreProvider<UndoableState>(
      store: store,
      child: MaterialApp(
        title: 'Redux Undo Demo',
        home: const MyHomePage(),

Contributors #

0.1.0+3 #

Critical Fix #

  • added a new helper function UndoableState createUndoableState(dynamic state) to initiate the UndoableState on init
  • renamed undoableReducer to Reducer<UndoableState> createUndoableReducer(dynamic reducer, { UndoConfig config }) to keep naming consistent

Updates #

  • reformatted some files with dartfrmt

0.1.0+2 #

  • reformatted some files with dartfrmt
  • added a bit of documentation

0.1.0+1 #

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  redux_undo: ^0.1.0+4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:redux_undo/redux_undo.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Format lib/src/reducer.dart.

Run dartfmt to format lib/src/reducer.dart.

Format lib/src/utils.dart.

Run dartfmt to format lib/src/utils.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (redux).

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and redux_undo.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
meta >=1.1.1 <2.0.0 1.1.8
redux >=3.0.0 <4.0.0 3.0.0 4.0.0
Dev dependencies
pedantic ^1.8.0