get_storage 1.1.1 get_storage: ^1.1.1 copied to clipboard
A fast, extra light and synchronous key-value storage written entirely in Dart
get_storage #
A fast, extra light and synchronous key-value storage written entirely in Dart to Get framework of Flutter.
Supports Android, iOS, Web, Mac, Linux, and fuchsia (Wip on Windows).
Add to your pubspec:
dependencies:
get_storage:
Initialize storage driver with await:
main() async {
await GetStorage.init();
runApp(App());
}
use GetStorage as instance:
GetStorage getx = GetStorage();
And use it. To write information you must use write
:
getx.write('quote', 'GetX is the best');
To read values you use read
:
print(getx.read('quote'));
// out: GetX is the best
To remove a key, you can use remove
:
getx.remove('quote');
To listen changes you can use listen
:
getx.listen((event) {print(event);});
If you subscribe to events, be sure to dispose them when using:
getx.dispose();
If you want to create different containers, simply give it a name. You can listen to specific containers, and also delete them.
GetStorage g = GetStorage('MyStorage');
To initialize specific container:
await GetStorage.init('MyStorage');