SharedPreferencesHydratedStorage class

A HydratedStorage backend implementation that persists state using SharedPreferences (from package:shared_preferences).

Example:

import 'package:bloc_signals_hydrate/bloc_signals_hydrate.dart';
import 'package:bloc_signals_hydrate/shared_preferences.dart';
import 'package:shared_preferences/shared_preferences.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final prefs = await SharedPreferences.getInstance();
  HydratedStorage.storage = SharedPreferencesHydratedStorage(prefs);

  runApp(const MyApp());
}
Implemented types

Constructors

SharedPreferencesHydratedStorage(dynamic _prefs, {String prefix = ''})
Creates a SharedPreferencesHydratedStorage adapter wrapping prefs.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
prefix → String
The prefix applied to all keys stored in SharedPreferences.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → FutureOr<void>
Clears all keys and values from storage.
override
delete(String key) → FutureOr<void>
Deletes value associated with key from storage.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(String key) → dynamic
Reads value associated with key from storage.
override
toString() → String
A string representation of this object.
inherited
write(String key, dynamic value) → FutureOr<void>
Writes value associated with key to storage.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited