getData<T> static method

Future<T?> getData<T>({
  1. required String key,
})

Get the stored data with key.

Implementation

static Future<T?> getData<T>({required String key}) async {
  final SharedPreferences prefs = await SharedPreferences.getInstance();
  await prefs.reload();

  final Object? data = prefs.get(_kPrefsKeyPrefix + key);

  return (data is T) ? data : null;
}