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.
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.
- simple_secure_storage
Secure key‑value storage for Flutter with platform‑specific backends.
77Compare - flutter_cache_manager
Generic cache manager for saving web files and cache info on device storage.
91Compare - storage_client
Dart client library to interact with Supabase Storage.
87Compare - fs_shim
Portable file system API working identically on io, web (IndexedDB/OPFS) and memory.
80Compare
Works with
Packages commonly used together with cross_local_storage: ones it builds on, ones built on it, and its own family.
- shared_preferencescross_local_storage depends on itFlutter plugin for reading and writing simple key-value pairs. Wraps NSUserDefaults on iOS and SharedPreferences on Android.
- cross_connectivitySame familyFlutter plugin to monitor real network connectivity across mobile, web, and desktop.
- cross_platformSame familyUnified API for detecting the current platform and basic system info across Flutter, web, and desktop.