Pub build coverage Star on GitHub License: MIT Starware

An extension to the cubit state management library which automatically persists and restores cubit states.

Creating a HydratedCubit

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

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

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

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

Using a HydratedCubit

void main() async {
  WidgetsFlutterBinding.ensureInitialized(); = await;
  final counterCubit = CounterCubit();

Dart Versions

  • Dart 2: >= 2.7.0



HydratedCubit 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. ⭐