Skip to content
pubscout

session_storage

0.0.1, released 4 years ago by jcquintas.dev

SessionStorage wrapper for web using an in-memory map fallback for other platforms.

WASM-ready
$ flutter pub add session_storage
Source repository

What it does

Allows manipulation of browser SessionStorage on the web platform while falling back to an in-memory map for other platforms. It uses a singleton pattern where instances share the same state.

AI-written summary of version 0.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need a cross-platform interface that talks to window.sessionStorage on the web
  • You want temporary key-value storage that acts like a Map and does not persist past the browser session on non-web platforms

Skip it when

  • You need persistent local storage across app restarts on mobile or desktop platforms
  • You require complex querying or relational database features

Strengths

  • Provides a unified Map-like API across web and non-web platforms
  • Shared static instance ensures state consistency across constructor calls
  • Extremely simple setup

Weaknesses

  • Non-web platforms only use an in-memory map, meaning data is lost when the app restarts
  • Very minimal feature set with no persistence support outside of the web's session storage

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:session_storage/session_storage.dart';

final session = SessionStorage();
session['language'] = 'english';

final newSession = SessionStorage();
print(newSession['language']); // english

Alternatives

Packages that do the same job and could replace session_storage.

  • shared_preferences

    Provides persistent key-value storage across all platforms instead of just an in-memory map fallback on non-web platforms.