packageSubtreeBytes function

int? packageSubtreeBytes(
  1. dynamic tree,
  2. String package
)

Sums the bytes of the package:<package> subtree of an analyze-size JSON tree: the node's own value (null on pure containers) plus every descendant's value, exactly as the DevTools size analysis accounts bytes.

Returns null when no such node exists (the app does not import the solution under that pub package name).

Implementation

int? packageSubtreeBytes(dynamic tree, String package) {
  if (tree is! Map<String, dynamic>) return null;
  final node = _findNode(tree, 'package:$package');
  if (node == null) return null;
  return _sumNode(node);
}