asList<T> method

List<T> asList<T>(
  1. String key, {
  2. List<T>? def,
})

Retrieves the list of type T associated with the key. If the key does not exist or the value cannot be parsed as a list, returns the def value.

key The key in the map to retrieve the value from. def The default value to return if the key is not found or the value cannot be parsed. Defaults to an empty list if not provided.

Returns: The list of type T associated with the key or def if not found or cannot be parsed.

Implementation

List<T> asList<T>(String key, {List<T>? def}) {
  if (keys.contains(key)) {
    return this[key].asList<T>(def: def);
  }

  return def ?? [];
}