diff options
Diffstat (limited to 'lib/util/storage_handler.dart')
-rw-r--r-- | lib/util/storage_handler.dart | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/util/storage_handler.dart b/lib/util/storage_handler.dart new file mode 100644 index 0000000..1e12ed7 --- /dev/null +++ b/lib/util/storage_handler.dart @@ -0,0 +1,20 @@ +import 'package:shared_preferences/shared_preferences.dart'; + +/// Handles all persistance related app storage +class StorageHandler { + /// Stores the given `data` as a string with the `key`. + static Future<String> store(String key, String data) async { + final _prefs = await SharedPreferences.getInstance(); + + _prefs.setString(key, data); + + return data; + } + + /// Fetches the string related to the given `key`. + static Future<String?> fetch(String key) async { + final _prefs = await SharedPreferences.getInstance(); + + return _prefs.getString(key); + } +} |