Search packages, repositories and app categories

Package detailsv6.0.0

localstorage

LocalStorage for Flutter. Alternative to React Native's AsyncStorage.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
13K
Likes
382
Pub points
160

Install package

flutter pub add localstorage

Package Overview

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

Localstorage is a Flutter package providing persistent key-value storage, serving as an alternative to React Native's AsyncStorage. It enables storing and retrieving data across app restarts on multiple platforms including Android, iOS, Web, macOS, Windows, and Linux. Built with simplicity in mind, it offers asynchronous operations for reading and writing strings, numbers, and JSON-serializable objects. The package abstracts platform-specific storage mechanisms, ensuring consistent behavior across environments. Ideal for caching, user preferences, or small-scale data persistence without requiring a full database.

Use cases

  • Storing user preferences
  • Caching API responses
  • Persisting app state
  • Saving form data
  • Managing authentication tokens

Key features

  • Cross-platform compatibility
  • Async read/write operations
  • JSON serialization support
  • Simple API
  • Lightweight and fast

Suitable for

  • Small-scale data persistence
  • Offline-first apps
  • User settings management
  • Prototyping
  • Apps needing lightweight storage

Considerations

  • Not suitable for large datasets
  • No built-in query capabilities
  • Data not encrypted by default
  • Limited to basic data types
  • Requires manual error handling

Original README

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

LocalStorage

LocalStorage for Flutter.

[!IMPORTANT]
LocalStorage is not intended to store large amounts or sensitive data.

Installation

flutter pub add localstorage

or add dependency to pubspec.yaml manually

dependencies:
  localstorage: ^5.0.0

API docs

LocalStorage API documentation

Usage

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

late final ValueNotifier<int> notifier;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await initLocalStorage();

  notifier = ValueNotifier(int.parse(localStorage.getItem('counter') ?? '0'));
  notifier.addListener(() {
    localStorage.setItem('counter', notifier.value.toString());
  });

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ValueListenableBuilder<int>(
            valueListenable: notifier,
            builder: (context, value, child) {
              return Text('Pressed $value times');
            },
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            notifier.value++;
          },
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}

Contributors

License

MIT

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package