8000 GitHub - fishofeyes/cross_local_storage: SharedPreferences wrapper for both Mobile (Android/iOS), Web and Desktop (Windows, macOS, Linux).
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

SharedPreferences wrapper for both Mobile (Android/iOS), Web and Desktop (Windows, macOS, Linux).

License

Notifications You must be signed in to change notification settings

fishofeyes/cross_local_storage

 
 

Repository files navigation

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: ^1.1.0

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.

About

SharedPreferences wrapper for both Mobile (Android/iOS), Web and Desktop (Windows, macOS, Linux).

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 42.5%
  • C++ 32.1%
  • Ruby 6.4%
  • Batchfile 5.9%
  • C 5.6%
  • HTML 2.6%
  • Other 4.9%
0