Allow 'flutter create' in dev and example directories (#74932)

This commit is contained in:
Jenn Magder
2021-01-28 15:24:09 -08:00
committed by GitHub
parent 234952cf29
commit bf248fade2
2 changed files with 35 additions and 4 deletions

View File

@@ -249,10 +249,16 @@ abstract class CreateBase extends FlutterCommand {
@protected
void validateProjectDir({bool overwrite = false}) {
if (globals.fs.path.isWithin(flutterRoot, projectDirPath)) {
throwToolExit(
'Cannot create a project within the Flutter SDK. '
"Target directory '$projectDirPath' is within the Flutter SDK at '$flutterRoot'.",
exitCode: 2);
// Make exception for dev and examples to facilitate example project development.
final String examplesDirectory = globals.fs.path.join(flutterRoot, 'examples');
final String devDirectory = globals.fs.path.join(flutterRoot, 'dev');
if (!globals.fs.path.isWithin(examplesDirectory, projectDirPath) &&
!globals.fs.path.isWithin(devDirectory, projectDirPath)) {
throwToolExit(
'Cannot create a project within the Flutter SDK. '
"Target directory '$projectDirPath' is within the Flutter SDK at '$flutterRoot'.",
exitCode: 2);
}
}
// If the destination directory is actually a file, then we refuse to