Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jcquintas/session_storage
Allows manipulation of SessionStorage on Web platform while using an in-memory map for other platforms.
https://github.com/jcquintas/session_storage
Last synced: 28 days ago
JSON representation
Allows manipulation of SessionStorage on Web platform while using an in-memory map for other platforms.
- Host: GitHub
- URL: https://github.com/jcquintas/session_storage
- Owner: JCQuintas
- License: mit
- Created: 2023-01-21T20:53:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-21T21:22:57.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T17:14:29.608Z (2 months ago)
- Language: Dart
- Homepage: https://pub.dev/packages/session_storage
- Size: 59.6 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# session_storage
[![Pub](https://img.shields.io/pub/v/session_storage.svg)](https://pub.dartlang.org/packages/session_storage)
## Getting Started
This is a very simple abstraction over a Map to allow usage of SessionStorage on any platform, but specifically intended to interact with window.sessionStorage on web without breaking other platforms.
### Programmatically
Install the library using your preferred method.
```bash
flutter pub add session_storage
```Then use the library, the `SessionStorage` class only exposes a single constructor, and it always shares the same static instance.
```dart
import 'package:session_storage/session_storage.dart';final session = SessionStorage();
// Use it like you would any other Map.
session['language'] = 'english';// Sessions are shared, so by calling the constructor again
// you will still have any value you previously set.
final newSession = SessionStorage();newSession['language'] == 'english' // true
```