getPubCachePath static method

String? getPubCachePath()

Gets the Dart/Flutter pub cache directory.

Implementation

static String? getPubCachePath() {
  final env = Platform.environment;
  final pubCache = env['PUB_CACHE'];
  if (pubCache != null && pubCache.isNotEmpty) {
    return PathUtils.resolveAbsolute(pubCache);
  }

  // Default locations
  final home = PathUtils.getHomeDirectory();
  if (home.isEmpty) return null;

  if (Platform.isWindows) {
    return PathUtils.resolveAbsolute(
        path.join(home, 'AppData', 'Local', 'Pub', 'Cache'));
  } else {
    return PathUtils.resolveAbsolute(path.join(home, '.pub-cache'));
  }
}