[tool][web] Create an early web plugin_registrant for dartpad. (#106921)

This commit is contained in:
David Iglesias
2022-07-01 17:51:06 -07:00
committed by GitHub
parent ed37c838e8
commit c4aaa394ac
3 changed files with 106 additions and 12 deletions

View File

@@ -1106,6 +1106,11 @@ Future<void> refreshPluginsList(
///
/// In the Web platform, `destination` can point to a real filesystem (`flutter build`)
/// or an in-memory filesystem (`flutter run`).
///
/// This method is also used by [WebProject.ensureReadyForPlatformSpecificTooling]
/// 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<void> injectBuildTimePluginFiles(
FlutterProject project, {
required Directory destination,

View File

@@ -734,7 +734,20 @@ class WebProject extends FlutterProjectPlatform {
.childDirectory('web')
.childFile('index.html');
Future<void> ensureReadyForPlatformSpecificTooling() async {}
/// The .dart_tool/dartpad directory
Directory get dartpadToolDirectory => parent.directory
.childDirectory('.dart_tool')
.childDirectory('dartpad');
Future<void> ensureReadyForPlatformSpecificTooling() async {
/// Create .dart_tool/dartpad/web_plugin_registrant.dart.
/// See: https://github.com/dart-lang/dart-services/pull/874
await injectBuildTimePluginFiles(
parent,
destination: dartpadToolDirectory,
webPlatform: true,
);
}
}
/// The Fuchsia sub project.