hydrated 1.2.1

  • README.md
  • Example
  • Installing
  • Versions
  • 80


Hydrated provides a BehaviorSubject that automatically persists to Flutter's local storage and hydrates on creation!

Easy to consume

All values are persisted with shared_preferences and restored with automatic hydration.

final count$ = HydratedSubject<int>("count", seedValue: 0);

/// count$ will automagically be hydrated with 42 next time it is created

Ready for BLoC

class HydratedBloc {
  final _count$ = HydratedSubject<int>("count", seedValue: 0);

  ValueObservable<int> get count$ => _count$.stream;
  Sink<int> get setCount => _count$.sink;

  dispose() {

Supports simple types and serialized classes

We support all shared_preferences types.

  • int
  • double
  • bool
  • String
  • List<String>
final count$ = HydratedSubject<int>("count");

We also support serialized classes with hydrate and persist arguments.

final user$ = HydratedSubject<User>(
  hydrate: (String s) => User.fromJSON(s),
  persist: (User user) => user.toJSON(),


Hydrated is mock tested with all supported types and is dogfooded by its creator.

demo of Hydrated tests completing successfully


demo of Hydrated BehaviorSubject between app restarts


The goal of Hydrated is to make persistence of BLoC classes as simple as possible for Flutter projects. PRs are welcome, but be warned that I am committed to simplicity.


  • Fix error thrown when onHydrate was null


  • Hydrate is now automagical


  • Improved docs


  • Fix docs, never gonna give up that build number


  • Add support for serialized classes, remove build number


  • Update docs


  • First release of Hydrated



A new Flutter project.

Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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

  hydrated: ^1.2.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:hydrated/hydrated.dart';
Version Uploaded Documentation Archive
1.2.1 Dec 24, 2018 Go to the documentation of hydrated 1.2.1 Download hydrated 1.2.1 archive
1.2.0 Dec 24, 2018 Go to the documentation of hydrated 1.2.0 Download hydrated 1.2.0 archive
1.1.0+4 Dec 22, 2018 Go to the documentation of hydrated 1.1.0+4 Download hydrated 1.1.0+4 archive
1.1.0+3 Dec 22, 2018 Go to the documentation of hydrated 1.1.0+3 Download hydrated 1.1.0+3 archive
1.1.0 Dec 22, 2018 Go to the documentation of hydrated 1.1.0 Download hydrated 1.1.0 archive
1.0.0+2 Dec 21, 2018 Go to the documentation of hydrated 1.0.0+2 Download hydrated 1.0.0+2 archive
1.0.0+1 Dec 20, 2018 Go to the documentation of hydrated 1.0.0+1 Download hydrated 1.0.0+1 archive
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 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
rxdart ^0.20.0 0.20.0
shared_preferences ^0.4.3 0.4.3
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies