Skip to main content

cell_flutter_persistence 0.1.0 copy "cell_flutter_persistence: ^0.1.0" to clipboard
cell_flutter_persistence: ^0.1.0 copied to clipboard

Persistence adapters for cell_flutter: durable state with SharedPreferences or custom backends.

cell_flutter_persistence #

Persistence adapters for cell_flutter: durable state backed by SharedPreferences or custom backends.

What it provides #

  • CellPersistenceAdapter<T> — the adapter contract (read / write / remove).
  • SharedPreferencesAdapter<T> — SharedPreferences-backed adapter with primitive and JSON codecs (SharedPreferencesAdapter.string, .integer, .json, …).
  • InMemoryAdapter<T> — deterministic, test-friendly adapter.
  • PersistedCell<T> / persistedState — a restorable state cell that hydrates from the adapter on load() and writes changes back in immediate, debounced, or on-app-pause modes.

Install #

dependencies:
  cell: ^2.0.0
  cell_flutter: ^1.0.0
  cell_flutter_persistence: ^0.1.0

Quick start #

import 'package:cell_flutter_persistence/cell_flutter_persistence.dart';

final counter = persistedState<int>(
  restorationId: 'counter',
  initial: 0,
  adapter: SharedPreferencesAdapter.integer(prefs),
);

// In initState:
CellRestorationScope.maybeOf(context)?.register(counter.cell);
counter.load(); // async; the cell updates when the read completes.

// Everywhere else:
counter.cell.value = 5; // restored + persisted (per writeMode)

WriteMode.immediate writes every change; WriteMode.debounced (default, 1s) writes after a quiet period and coalesces bursts; WriteMode.onAppPause writes when handleAppPaused is called from a WidgetsBindingObserver.

See test/ for the full contract coverage and the package CHANGELOG.md for release history.

0
likes
150
points
93
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Persistence adapters for cell_flutter: durable state with SharedPreferences or custom backends.

Repository (GitHub)
View/report issues

License

Apache-2.0, MIT (license)

Dependencies

cell, cell_flutter, flutter, shared_preferences

More

Packages that depend on cell_flutter_persistence