Skip to content
pubscout

cross_local_storage

3.1.0, released a year ago by thisismarch.dev

SharedPreferences wrapper for Mobile, Web, and Desktop with JSON file storage support.

WASM-ready
$ flutter pub add cross_local_storage
Source repository

What it does

It provides a cross-platform persistent store interface wrapping NSUserDefaults, SharedPreferences, LocalStorage on Web, and JSON files on Desktop platforms. Data is persisted asynchronously.

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

Use it when

  • You need simple key-value storage across Android, iOS, Web, Windows, macOS, and Linux.
  • You want a unified SharedPreferences-like API that also works on desktop operating systems.

Skip it when

  • You are storing critical data, as writes are not guaranteed to persist immediately.
  • You need complex relational queries or encrypted secure storage.

Strengths

  • Supports all major platforms including desktop via JSON files.
  • Familiar SharedPreferences-like interface.

Weaknesses

  • Writes cannot be guaranteed to persist to disk after returning.
  • Not suitable for critical data storage.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1

not documented

import 'package:flutter/material.dart';
import 'package:cross_local_storage/cross_local_storage.dart';

void main() async {
  LocalStorageInterface prefs = await LocalStorage.getInstance();
  int counter = (prefs.getInt('counter') ?? 0) + 1;
  await prefs.setInt('counter', counter);
}

Alternatives

Packages that do the same job and could replace cross_local_storage.

Works with

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