Skip to content

📦flutter localstorage for ios/android/desktop/web

License

Notifications You must be signed in to change notification settings

kee-org/flutter_localstorage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Localstorage

Simple json file-based storage for flutter

lesnitsky.dev GitHub stars Twitter Follow

Installation

Add dependency to pubspec.yaml

dependencies:
  ...
  localstorage: ^3.0.6

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

lesnitsky.dev GitHub stars Twitter Follow

About

📦flutter localstorage for ios/android/desktop/web

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 76.2%
  • Ruby 12.1%
  • HTML 5.1%
  • Swift 2.7%
  • Shell 2.0%
  • Kotlin 1.6%
  • Objective-C 0.3%