asListOfMap method

List<Map<String, dynamic>>? asListOfMap(
  1. String key, {
  2. bool throwOnNull = true,
})

Implementation

List<Map<String, dynamic>>? asListOfMap(
  String key, {
  bool throwOnNull = true,
}) {
  final List? value = as(key);
  if (value == null) {
    if (!throwOnNull) {
      return null;
    }
    throw DartSuiPluginException(
      'Key not found.',
      details: {'key': key, 'data': this},
    );
  }
  try {
    return value.map((e) => (e as Map).cast<String, dynamic>()).toList();
  } catch (e, s) {
    throw DartSuiPluginException(
      'Incorrect value.',
      details: {
        'key': key,
        'value': value.runtimeType,
        'data': this,
        'error': e.toString(),
        'stack': s.toString(),
      },
    );
  }
}