diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 13a1be53cb..f50d5b98a6 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -143,6 +143,14 @@ class CreateCommand extends FlutterCommand { defaultsTo: false, help: 'Generate a project using the AndroidX support libraries', ); + argParser.addFlag( + 'web', + negatable: true, + defaultsTo: false, + hide: true, + help: '(Experimental) Generate the web specific tooling. Only supported ' + 'on non-stable branches', + ); } @override @@ -367,6 +375,7 @@ class CreateCommand extends FlutterCommand { androidX: argResults['androidx'], androidLanguage: argResults['android-language'], iosLanguage: argResults['ios-language'], + web: argResults['web'], ); final String relativeDirPath = fs.path.relative(projectDirPath); @@ -576,6 +585,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi String flutterRoot, bool renderDriverTest = false, bool withPluginHook = false, + bool web = false, }) { flutterRoot = fs.path.normalize(flutterRoot); @@ -603,6 +613,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi 'iosLanguage': iosLanguage, 'flutterRevision': FlutterVersion.instance.frameworkRevision, 'flutterChannel': FlutterVersion.instance.channel, + 'web': web && !FlutterVersion.instance.isStable, }; } diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index 03efe52f69..2ea276e2b2 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -586,23 +586,7 @@ class WebProject { /// The html file used to host the flutter web application. File get indexFile => parent.directory.childDirectory('web').childFile('index.html'); - Future ensureReadyForPlatformSpecificTooling() async { - /// Generate index.html in build/web. Eventually we could support - /// a custom html under the web sub directory. - final Directory outputDir = fs.directory(getWebBuildDirectory()); - if (!outputDir.existsSync()) { - outputDir.createSync(recursive: true); - } - final Template template = Template.fromName('web/index.html.tmpl'); - template.render( - outputDir, - { - 'appName': parent.manifest.appName, - }, - printStatusWhenWriting: false, - overwriteExisting: true, - ); - } + Future ensureReadyForPlatformSpecificTooling() async {} } /// Deletes [directory] with all content. diff --git a/packages/flutter_tools/lib/src/template.dart b/packages/flutter_tools/lib/src/template.dart index 97bc18b63b..943730c2dd 100644 --- a/packages/flutter_tools/lib/src/template.dart +++ b/packages/flutter_tools/lib/src/template.dart @@ -85,6 +85,11 @@ class Template { return null; relativeDestinationPath = relativeDestinationPath.replaceAll('$platform-$language.tmpl', platform); } + // Only build a web project if explicitly asked. + final bool web = context['web']; + if (relativeDestinationPath.contains('web') && !web) { + return null; + } final String projectName = context['projectName']; final String androidIdentifier = context['androidIdentifier']; final String pluginClass = context['pluginClass']; diff --git a/packages/flutter_tools/templates/app/web/index.html.tmpl b/packages/flutter_tools/templates/app/web/index.html.tmpl new file mode 100644 index 0000000000..34621ea01c --- /dev/null +++ b/packages/flutter_tools/templates/app/web/index.html.tmpl @@ -0,0 +1,10 @@ + + + + + {{projectName}} + + + + + diff --git a/packages/flutter_tools/templates/web/index.html.tmpl b/packages/flutter_tools/templates/web/index.html.tmpl deleted file mode 100644 index 96507b54d5..0000000000 --- a/packages/flutter_tools/templates/web/index.html.tmpl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - {{appName}} - - - - -