getData<T> method Null safety

Future<T> getData<T>(
  1. String key
)

Implementation

Future<T> getData<T>(String key) async {
  // Get SharedPreferences ref
  final SharedPreferences ref = await preferences;
  // Get data by key with cast to output data type
  return ref.get(key) as T;
}