hydrated 1.2.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 87

Hydrated #

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(),

Reliable #

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

demo of Hydrated tests completing successfully

Demo #

demo of Hydrated BehaviorSubject between app restarts

Contributing #

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.

1.2.3 #

  • Bump rx_dart version to ^0.22.0

1.2.3 #

  • Bump rx_dart version to ^0.21.0 (thanks to ccadieux!)

1.2.2 #

  • Bump shared_preferences version to ^0.5.1

1.2.1 #

  • Fix error thrown when onHydrate was null

1.2.0 #

  • Hydrate is now automagical

1.1.0+4 #

  • Improved docs

1.1.0+3 #

  • Fix docs, never gonna give up that build number

1.1.0 #

  • Add support for serialized classes, remove build number

1.0.0+2 #

  • Update docs

1.0.0+1 #

  • First release of Hydrated


hydrated_demo #

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.4

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support 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:hydrated/hydrated.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 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

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 (rxdart).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
rxdart ^0.22.0 0.22.6 0.23.1
shared_preferences ^0.5.1 0.5.6
Transitive dependencies
collection 1.14.11 1.14.12
flutter_web_plugins 0.0.0
meta 1.1.8
shared_preferences_macos 0.0.1+3
shared_preferences_platform_interface 1.0.1
shared_preferences_web 0.1.2+2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies