hydrated 1.1.0+3 copy "hydrated: ^1.1.0+3" to clipboard
hydrated: ^1.1.0+3 copied to clipboard

outdated

An automatically persisted BehaviorSubject with simple hydration for Flutter. Intended for use with the BLoC pattern.

Hydrated #

Hydrated provides a BehaviorSubject that automatically persists to Flutter's local storage. An async hydrate() method rehydrates on command!

Easy to consume #

All values are persisted with shared_preferences and restored with hydrate() at next app launch.

final count$ = HydratedSubject<int>("count", seedValue: 0); // persist
await count$.hydrate(); // hydrate

count$.add(42); // this value will be available on next app launch

Ready for BLoC #

class _Bloc {
  /// persist
  final count$ = HydratedSubject<int>("count", seedValue: 0);

  _Bloc() {
    /// hydrate
    this.count$.hydrate();
  }

  // ...
}

Supports types and 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 BehaviorSubject between app restarts
28
likes
0
pub points
65%
popularity

Publisher

verified publishersolid.software

An automatically persisted BehaviorSubject with simple hydration for Flutter. Intended for use with the BLoC pattern.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, rxdart, shared_preferences

More

Packages that depend on hydrated