scanInstalledBundle function

Future<BundleScanResult?> scanInstalledBundle()

Walks the running app's own installed bundle and sums it up into the same tree shape SizeAnalysisNode.fromJson produces, so it renders through the exact same treemap/breakdown UI. iOS/macOS/Windows/Linux walk the real .app/install directory directly; Android has no such directory to walk, so it parses its own installed APK(s) as zip archives instead. Web has neither, and resolves to null.

Implementation

Future<BundleScanResult?> scanInstalledBundle() async {
  if (Platform.isAndroid) return _scanAndroidApk();
  if (Platform.isFuchsia) return null;

  final bundleDir = _findBundleRoot();
  if (bundleDir == null) return null;

  try {
    final root = await _scan(bundleDir).timeout(_scanTimeout);
    return BundleScanResult(root: root, platformLabel: Platform.operatingSystem);
  } catch (_) {
    return null;
  }
}