getStringList method

List<String>? getStringList(
  1. String key
)

Reads a list of string values from the cache, throwing an exception if it's not a string list.

Throws an ArgumentError if key is not in this instance's filter.

Implementation

List<String>? getStringList(String key) {
  if (!_isValidKey(key)) {
    throw ArgumentError(
        '$key is not included in the PreferencesFilter allowlist');
  }
  // Make a copy of the list so that later mutations won't propagate
  return (_cache[key] as List<Object?>?)?.cast<String>().toList();
}