asListOfBytes method

List<List<int>>? asListOfBytes(
  1. String key, {
  2. bool throwOnNull = true,
})

Implementation

List<List<int>>? asListOfBytes(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 List).cast<int>()).toList();
  } catch (e, s) {
    throw DartSuiPluginException(
      'Incorrect value.',
      details: {
        'key': key,
        'value': value.runtimeType,
        'data': this,
        'error': e.toString(),
        'stack': s.toString(),
      },
    );
  }
}