tryGetList<T> method

List<T>? tryGetList<T>(
  1. String key, [
  2. TryGet log = TryGet.optional
])

Implementation

List<T>? tryGetList<T>(String key, [TryGet log = TryGet.optional]) {
  final Object? value = this[key];
  if (value is! List) {
    log(key, T, value.runtimeType);
    return null;
  }
  try {
    // copy entries to ensure type check failures here and not an access
    return value.cast<T>().toList();
  } catch (_) {
    Logs().v(
        'Unable to create "List<$T>" in event content for the key "$key" at ${StackTrace.current.firstLine}');
    return null;
  }
}