From 8d7513efb6440d52769683f8bde667860e80afd0 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Thu, 31 Oct 2024 15:48:23 -0700 Subject: [PATCH] Renames `injectBuildTimePluginFilesForWebPlatform` and removes unused named parameter. (#157944) Closes https://github.com/flutter/flutter/issues/157943. --------- Co-authored-by: Andrew Kolos --- .../flutter_tools/lib/src/build_system/targets/web.dart | 5 ++++- packages/flutter_tools/lib/src/flutter_plugins.dart | 9 +++------ .../lib/src/isolated/resident_web_runner.dart | 5 ++++- packages/flutter_tools/lib/src/project.dart | 3 +-- .../flutter_tools/test/general.shard/plugins_test.dart | 7 +++++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/flutter_tools/lib/src/build_system/targets/web.dart b/packages/flutter_tools/lib/src/build_system/targets/web.dart index 77e72f1144..0fc2507829 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/web.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/web.dart @@ -79,7 +79,10 @@ class WebEntrypointTarget extends Target { final String importedEntrypoint = packageConfig.toPackageUri(importUri)?.toString() ?? importUri.toString(); - await injectBuildTimePluginFiles(flutterProject, webPlatform: true, destination: environment.buildDir); + await injectBuildTimePluginFilesForWebPlatform( + flutterProject, + destination: environment.buildDir, + ); // The below works because `injectBuildTimePluginFiles` is configured to write // the web_plugin_registrant.dart file alongside the generated main.dart const String generatedImport = 'web_plugin_registrant.dart'; diff --git a/packages/flutter_tools/lib/src/flutter_plugins.dart b/packages/flutter_tools/lib/src/flutter_plugins.dart index d03ab3f59a..a7dd5bd4fc 100644 --- a/packages/flutter_tools/lib/src/flutter_plugins.dart +++ b/packages/flutter_tools/lib/src/flutter_plugins.dart @@ -1051,16 +1051,13 @@ Future refreshPluginsList( /// to inject a copy of the plugin registrant for web into .dart_tool/dartpad so /// dartpad can get the plugin registrant without needing to build the complete /// project. See: https://github.com/dart-lang/dart-services/pull/874 -Future injectBuildTimePluginFiles( +Future injectBuildTimePluginFilesForWebPlatform( FlutterProject project, { required Directory destination, - bool webPlatform = false, }) async { final List plugins = await findPlugins(project); final Map> pluginsByPlatform = _resolvePluginImplementations(plugins, pluginResolutionType: _PluginResolutionType.nativeOrDart); - if (webPlatform) { - await _writeWebPluginRegistrant(project, pluginsByPlatform[WebPlugin.kConfigKey]!, destination); - } + await _writeWebPluginRegistrant(project, pluginsByPlatform[WebPlugin.kConfigKey]!, destination); } /// Injects plugins found in `pubspec.yaml` into the platform-specific projects. @@ -1071,7 +1068,7 @@ Future injectBuildTimePluginFiles( /// Files written by this method end up in platform-specific locations that are /// configured by each [FlutterProject] subclass (except for the Web). /// -/// Web tooling uses [injectBuildTimePluginFiles] instead, which places files in the +/// Web tooling uses [injectBuildTimePluginFilesForWebPlatform] instead, which places files in the /// current build (temp) directory, and doesn't modify the users' working copy. /// /// Assumes [refreshPluginsList] has been called since last change to `pubspec.yaml`. diff --git a/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart b/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart index 3fccf70ef0..40473a060d 100644 --- a/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart @@ -532,7 +532,10 @@ Please provide a valid TCP port (an integer between 0 and 65535, inclusive). result = _generatedEntrypointDirectory!.childFile('web_entrypoint.dart'); // Generates the generated_plugin_registrar - await injectBuildTimePluginFiles(flutterProject, webPlatform: true, destination: _generatedEntrypointDirectory!); + await injectBuildTimePluginFilesForWebPlatform( + flutterProject, + destination: _generatedEntrypointDirectory!, + ); // The below works because `injectBuildTimePluginFiles` is configured to write // the web_plugin_registrant.dart file alongside the generated main.dart const String generatedImport = 'web_plugin_registrant.dart'; diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index 08bc45fb8a..1fa76f7bfa 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -1004,10 +1004,9 @@ class WebProject extends FlutterProjectPlatform { Future ensureReadyForPlatformSpecificTooling() async { /// Create .dart_tool/dartpad/web_plugin_registrant.dart. /// See: https://github.com/dart-lang/dart-services/pull/874 - await injectBuildTimePluginFiles( + await injectBuildTimePluginFilesForWebPlatform( parent, destination: dartpadToolDirectory, - webPlatform: true, ); } } diff --git a/packages/flutter_tools/test/general.shard/plugins_test.dart b/packages/flutter_tools/test/general.shard/plugins_test.dart index 86b627433a..4d2593c08c 100644 --- a/packages/flutter_tools/test/general.shard/plugins_test.dart +++ b/packages/flutter_tools/test/general.shard/plugins_test.dart @@ -933,7 +933,10 @@ dependencies: addToPackageConfig('web_plugin_with_nested', webPluginWithNestedFile); final Directory destination = flutterProject.directory.childDirectory('lib'); - await injectBuildTimePluginFiles(flutterProject, webPlatform: true, destination: destination); + await injectBuildTimePluginFilesForWebPlatform( + flutterProject, + destination: destination, + ); final File registrant = flutterProject.directory .childDirectory('lib') @@ -986,7 +989,7 @@ dependencies: flutterProject.isModule = true; final Directory destination = flutterProject.directory.childDirectory('lib'); - await injectBuildTimePluginFiles(flutterProject, webPlatform: true, destination: destination); + await injectBuildTimePluginFilesForWebPlatform(flutterProject, destination: destination); final File registrant = flutterProject.directory .childDirectory('lib')