setMockInitialValues static method

  1. @visibleForTesting
void setMockInitialValues(
  1. Map<String, Object> values
)

Initializes the shared preferences with mock values for testing.

If the singleton instance has been initialized already, it is nullified.

Implementation

@visibleForTesting
static void setMockInitialValues(Map<String, Object> values) {
  final Map<String, Object> newValues =
      values.map<String, Object>((String key, Object value) {
    String newKey = key;
    if (!key.startsWith(_prefix)) {
      newKey = '$_prefix$key';
    }
    return MapEntry<String, Object>(newKey, value);
  });
  SharedPreferencesStorePlatform.instance =
      InMemorySharedPreferencesStore.withData(newValues);
  _completer = null;
}