aboutsummaryrefslogtreecommitdiff
path: root/lib/util/storage_handler.dart
blob: fe27b9393522119f234d44ec06c55ba45640a50d (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 app data persistence 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);
  }
}