cleanDartPubGetGeneratedFiles method
Deletes files generated by dart pub get
:
confirmProjectName
the project name atpubspec.yaml
, to confirm cleanup.
Deleted Files:
- %projectDirectory/pubspec.lock
- %projectDirectory/.packages
- %projectDirectory/.dart_tool/**
Implementation
Future<bool> cleanDartPubGetGeneratedFiles(
{required String confirmProjectName, bool verbose = false}) async {
var projDir = await projectDirectory;
if (!projDir.existsSync()) {
return false;
}
var packageName = await projectPackageName;
if (packageName != confirmProjectName) {
return false;
}
var filePubspecLock = await projectSubFile('pubspec.lock');
var filePackages = await projectSubFile('.packages');
var dirDartTools = await projectSubDirectory('.dart_tool');
deleteFile(projDir, filePubspecLock, verbose: verbose);
deleteFile(projDir, filePackages, verbose: verbose);
if (dirDartTools.existsSync()) {
deleteDirectory(projDir, dirDartTools, recursive: true, verbose: verbose);
}
return true;
}