getAsList<T> method

List<T> getAsList<T>(
  1. K key, [
  2. List<T>? orElse

Retrieves the element of key of type List from Map.

If Map does not have an element of key or the type does not match List<T>, orElse is returned.




List<T> getAsList<T>(K key, [List<T>? orElse]) {
  assert(key != null, "The key is empty.");
  if (!containsKey(key) || this[key] is! List?) {
    return orElse ?? [];
  return (this[key] as List?)?.cast<T>() ?? orElse ?? [];