removeUnusedDir static method

void removeUnusedDir(
  1. String pathApps,
  2. String appsName
)

Removes platform-specific directories that are not needed for packages.

This method deletes platform-specific directories that are created by 'flutter create' but are not needed for package modules.

Parameters:

  • pathApps: The path to the new app module
  • appsName: The name of the new app module (unused but kept for consistency)

Implementation

static void removeUnusedDir(String pathApps, String appsName) {
  final platformDirs = [
    p.join(pathApps, 'android'),
    p.join(pathApps, 'ios'),
    p.join(pathApps, 'web'),
    p.join(pathApps, 'macos'),
    p.join(pathApps, 'linux'),
    p.join(pathApps, 'windows'),
  ];

  for (var element in platformDirs) {
    if (Directory(element).existsSync()) {
      try {
        Directory(element).deleteSync(recursive: true);
      } catch (e) {
        StatusHelper.warning('Failed to delete $element: $e');
      }
    }
  }
}