Search packages, repositories and app categories

Package detailsv3.1.0

cross_local_storage

SharedPreferences wrapper for both Mobile (Android/iOS), Web and Desktop (Windows, macOS, Linux). Also provides JSON file storage.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
343
Likes
32
Pub points
160

Install package

flutter pub add cross_local_storage

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

CrossLocalStorage is a Flutter/Dart package that provides a unified interface for persistent storage across mobile (Android/iOS), web, and desktop platforms (Windows, macOS, Linux). It wraps SharedPreferences for mobile and web while offering JSON file-based storage for desktop environments. The package ensures consistent data access regardless of platform, simplifying cross-platform app development. It supports both key-value storage and structured JSON file persistence, making it ideal for storing user preferences, app state, or small datasets reliably.

Use cases

  • Storing user preferences across platforms
  • Persisting app state in multi-platform apps
  • Saving configuration files as JSON
  • Managing local data in web and desktop apps
  • Sharing simple data between mobile and desktop
  • Enabling offline-first functionality

Key features

  • Unified API for all platforms
  • JSON file storage on desktop
  • SharedPreferences fallback on mobile/web
  • Platform-agnostic data access
  • Supports string, int, bool, and complex types
  • Automatic serialization/deserialization

Suitable for

  • Cross-platform Flutter developers
  • Apps requiring local persistence on multiple targets
  • Developers avoiding platform-specific code
  • Projects using JSON for local data
  • Teams prioritizing code reuse
  • Apps needing lightweight local storage

Considerations

  • Not suitable for large-scale data
  • JSON file storage may impact performance on desktop
  • Limited to simple data structures
  • No built-in encryption
  • Requires careful handling of file paths on desktop
  • Not designed for high-frequency writes

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

cross_local_storage

Build Pub GitHub GitHub stars

Wraps NSUserDefaults (on iOS and macOS), SharedPreferences (on Android), LocalStorage (on Web) and JSON file (on Windows and Linux), providing a persistent store for simple data. Data is persisted to disk asynchronously. Neither platform can guarantee that writes will be persisted to disk after returning and this plugin must not be used for storing critical data.

Getting Started

In order to use this plugin, add dependency in the pubspec.yaml:

cross_local_storage: any

or

cross_local_storage:
  git:
    url: https://github.com/marchdev-tk/cross_local_storage

Add an import to dart file:

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

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      body: Center(
      child: RaisedButton(
        onPressed: _incrementCounter,
        child: Text('Increment Counter'),
        ),
      ),
    ),
  ));
}

_incrementCounter() async {
  LocalStorageInterface prefs = await LocalStorage.getInstance();
  int counter = (prefs.getInt('counter') ?? 0) + 1;
  print('Pressed $counter times.');
  await prefs.setInt('counter', counter);

Feature requests and Bug reports

Feel free to post a feature requests or report a bug here.

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.