localstorage 4.0.1+4 copy "localstorage: ^4.0.1+4" to clipboard
localstorage: ^4.0.1+4 copied to clipboard

Simple json file-based storage for flutter. Alternative to react-native AsyncStorage

Localstorage #

Simple json file-based storage for flutter

Installation #

Add dependency to pubspec.yaml

dependencies:
  ...
  localstorage: ^4.0.0+1

Run in your terminal

flutter packages get

Example #

class SomeWidget extends StatelessWidget {
  final LocalStorage storage = new LocalStorage('some_key');

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: storage.ready,
      builder: (BuildContext context, snapshot) {
        if (snapshot.data == true) {
          Map<String, dynamic> data = storage.getItem('key');

          return SomeDataView(data: data);
        } else {
          return SomeLoadingStateWidget();
        }
      },
    );
  }
}

V2 -> v3 migration #

V3 doesn't add .json extension to a storage filename, so you need to do this on your own if you need a "migration". If you were using v2 with code like below:

final storage = new LocalStorage('my_data');

v3 equivalent:

final storage = new LocalStorage('my_data.json')

Integration tests #

cd ~/flutter_localstorage/test
flutter packages get
flutter drive --target=lib/main.dart

License #

MIT

337
likes
130
pub points
98%
popularity

Publisher

verified publisherlesnitsky.dev

Simple json file-based storage for flutter. Alternative to react-native AsyncStorage

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, path_provider

More

Packages that depend on localstorage