safeGetList<T> method

List<T>? safeGetList<T>(
  1. dynamic key
)

Implementation

List<T>? safeGetList<T>(dynamic key) {
  var value = this[key];
  if (value is List) {
    if (value.isEmpty) {
      return List<T>.empty(growable: true);
    }
    return value
        .whereType<T>()
        .map((e) => e)
        .toList(growable: true);
  } else {
    return null;
  }
}