Skip to content
pubscout

localstorage

6.0.0, released 2 years ago by lesnitsky.dev

LocalStorage for Flutter and Web, alternative to React Native's AsyncStorage.

WASM-ready
$ flutter pub add localstorage
Source repository

What it does

Provides a simple local key-value storage mechanism for Flutter applications, supporting Android, iOS, Web, Windows, macOS, and Linux. It exposes a synchronous API consistent with the web window.localStorage.

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

Use it when

  • You need a simple key-value storage solution similar to web localStorage.
  • You want to store small amounts of non-sensitive configuration or state data.

Skip it when

  • You need to store large amounts of data.
  • You need to store sensitive or highly secure data.

Strengths

  • Synchronous API that is consistent with web window.localStorage
  • Cross-platform support including Web, WASM, mobile, and desktop.

Weaknesses

  • Not intended for large amounts of data
  • Not intended for sensitive data

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
3

Call initLocalStorage() after WidgetsFlutterBinding.ensureInitialized() before usage.

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await initLocalStorage();
  localStorage.setItem('counter', '0');
  String? value = localStorage.getItem('counter');
}

Alternatives

Packages that do the same job and could replace localstorage.

Works with

Packages commonly used together with localstorage: ones it builds on, ones built on it, and its own family.