getInstance static method

Future<SharedPreferences> getInstance()

Implementation

static Future<SharedPreferences> getInstance() async {
  if (_completer == null) {
    final Completer<SharedPreferences> completer =
    Completer<SharedPreferences>();
    try {
      final Map<String, Object> preferencesMap =
      await _getSharedPreferencesMap();
      completer.complete(SharedPreferences._(preferencesMap));
    } on Exception catch (e) {
      completer.completeError(e);
      final Future<SharedPreferences> sharedPrefsFuture = completer.future;
      _completer = null;
      return sharedPrefsFuture;
    }
    _completer = completer;
  }
  return _completer!.future;
}