hydrated 1.2.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 86

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
count$.add(42);

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() {
    _count$.close();
  }
}

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>(
  "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.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

example/README.md

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:


dependencies:
  hydrated: ^1.2.0

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';
  
Version Uploaded Documentation Archive
1.2.3 May 8, 2019 Go to the documentation of hydrated 1.2.3 Download hydrated 1.2.3 archive
1.2.2 Feb 22, 2019 Go to the documentation of hydrated 1.2.2 Download hydrated 1.2.2 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
Popularity:
Describes how popular the package is relative to other packages. [more]
73
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on May 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.16
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

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 0.22.0
shared_preferences ^0.4.3 0.4.3 0.5.2+1
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
flutter_test