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