find<T> function Null safety

T? find<T>(
  1. Map<String, T> container,
  2. String? id
)

Implementation

T? find<T>(Map<String, T> container, String? id) {
  if (id == null) return null;
  final item = container[id];
  if (item == null) {
    final current = StackTrace.current
        .toString()
        .split("\n")
        .take(5)
        .map((frame) => "\t$frame")
        .join("\n");
    _log.warning("WARN: Item with id $id not found: $current");
  }
  return item;
}