aboutsummaryrefslogtreecommitdiff
path: root/lib/util/storage_handler.dart
blob: 1e12ed7be33bd002caa67d63cadb70c6b8d12faa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
  }
}