Simple json file-based storage for flutter
Add dependency to pubspec.yaml
dependencies:
...
localstorage: ^2.0.0
Run in your terminal
flutter packages get
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();
}
},
);
}
}
cd ~/flutter_localstorage/test
flutter packages get
flutter drive --target=lib/main.dart
MIT