getPackageName method
Implementation
String getPackageName(String basePath) {
// Try to determine the package name from pubspec.yaml
final projectDir = basePath.split('lib')[0];
final pubspecFile = File(path.join(projectDir, 'pubspec.yaml'));
try {
if (pubspecFile.existsSync()) {
final content = pubspecFile.readAsStringSync();
final nameRegex = RegExp(r'name:\s+([^\s]+)');
final match = nameRegex.firstMatch(content);
if (match != null && match.groupCount >= 1) {
return match.group(1)!;
}
}
} catch (e) {
// Fallback if unable to determine package name
}
// Default fallback
return 'app';
}