replay_cubit 0.2.0 copy "replay_cubit: ^0.2.0" to clipboard
replay_cubit: ^0.2.0 copied to clipboard

discontinued

An extension to the cubit state management library which adds support for undo and redo.

Cubit

Pub build coverage Star on GitHub License: MIT Starware

An extension to the cubit state management library which adds support for undo and redo.

Creating a ReplayCubit #

class CounterCubit extends ReplayCubit<int> {
  CounterCubit() : super(0);

  void increment() => emit(state + 1);
}

Using a ReplayCubit #

void main() {
  final cubit = CounterCubit();

  // trigger a state change
  cubit.increment();
  print(cubit.state); // 1

  // undo the change
  cubit.undo();
  print(cubit.state); // 0

  // redo the change
  cubit.redo();
  print(cubit.state); // 1
}

ReplayMixin #

If you wish to be able to use a ReplayCubit in conjuction with a different type of cubit like HydratedCubit, you can use the ReplayMixin.

class CounterCubit extends HydratedCubit<int> with ReplayMixin<int> {
  CounterCubit() : super(0);

  void increment() => emit(state + 1);
  void decrement() => emit(state - 1);

  @override
  int fromJson(Map<String, dynamic> json) => json['value'] as int;

  @override
  Map<String, int> toJson(int state) => {'value': state};
}

Dart Versions #

  • Dart 2: >= 2.7.0

Maintainers #

Starware #

ReplayCubit is Starware.
This means you're free to use the project, as long as you star its GitHub repository.
Your appreciation makes us grow and glow up. ⭐

11
likes
40
pub points
47%
popularity

Publisher

verified publisherbloc-dev.com

An extension to the cubit state management library which adds support for undo and redo.

Repository (GitHub)
View/report issues
Contributing

License

MIT (LICENSE)

Dependencies

cubit

More

Packages that depend on replay_cubit