getList method

List<Map<String, dynamic>>? getList(
  1. String key, [
  2. String? orKey
])

Get a List<Map<String, dynamic>>> from a map.

Implementation

List<Map<String, dynamic>>? getList(String key, [String? orKey]) {
  var v = this[key];
  if (v == null) {
    if (orKey != null) {
      v = this[orKey];
      if (v == null) {
        return null;
      }
    } else {
      return null;
    }
  }
  if (v is! List<dynamic>) {
    throw Exception('Invalid type: ${v.runtimeType} should be of type List');
  }

  return v.toList().cast<Map<String, dynamic>>();
}