55import 'package:args/args.dart' ;
66import 'package:meta/meta.dart' ;
77import 'package:package_config/package_config.dart' ;
8- import 'package:process/process.dart' ;
98
10- import '../artifacts.dart' ;
119import '../base/common.dart' ;
1210import '../base/deferred_component.dart' ;
1311import '../base/file_system.dart' ;
@@ -26,8 +24,6 @@ import '../linux/build_linux.dart';
2624import '../macos/build_macos.dart' ;
2725import '../project.dart' ;
2826import '../runner/flutter_command.dart' ;
29- import '../runner/flutter_command_runner.dart' ;
30- import '../widget_preview/dtd_services.dart' ;
3127import '../widget_preview/preview_code_generator.dart' ;
3228import '../widget_preview/preview_detector.dart' ;
3329import '../widget_preview/preview_manifest.dart' ;
@@ -45,8 +41,6 @@ class WidgetPreviewCommand extends FlutterCommand {
4541 required Platform platform,
4642 required ShutdownHooks shutdownHooks,
4743 required OperatingSystemUtils os,
48- required ProcessManager processManager,
49- required Artifacts artifacts,
5044 }) {
5145 addSubcommand (
5246 WidgetPreviewStartCommand (
@@ -58,8 +52,6 @@ class WidgetPreviewCommand extends FlutterCommand {
5852 platform: platform,
5953 shutdownHooks: shutdownHooks,
6054 os: os,
61- processManager: processManager,
62- artifacts: artifacts,
6355 ),
6456 );
6557 addSubcommand (
@@ -126,8 +118,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
126118 required this .platform,
127119 required this .shutdownHooks,
128120 required this .os,
129- required this .processManager,
130- required this .artifacts,
131121 }) {
132122 addPubOptions ();
133123 argParser
@@ -162,9 +152,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
162152 static const String kHeadlessWeb = 'headless-web' ;
163153 static const String kWidgetPreviewScaffoldOutputDir = 'scaffold-output-dir' ;
164154
165- /// Environment variable used to pass the DTD URI to the widget preview scaffold.
166- static const String kWidgetPreviewDtdUriEnvVar = 'WIDGET_PREVIEW_DTD_URI' ;
167-
168155 @override
169156 Future <Set <DevelopmentArtifact >> get requiredArtifacts async => const < DevelopmentArtifact > {
170157 // Ensure the Flutter Web SDK is installed.
@@ -198,10 +185,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
198185
199186 final OperatingSystemUtils os;
200187
201- final ProcessManager processManager;
202-
203- final Artifacts artifacts;
204-
205188 late final FlutterProject rootProject = getRootProject ();
206189
207190 late final PreviewDetector _previewDetector = PreviewDetector (
@@ -220,12 +203,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
220203 cache: cache,
221204 );
222205
223- late final WidgetPreviewDtdServices _dtdService = WidgetPreviewDtdServices (
224- logger: logger,
225- shutdownHooks: shutdownHooks,
226- dtdLauncher: DtdLauncher (logger: logger, artifacts: artifacts, processManager: processManager),
227- );
228-
229206 /// The currently running instance of the widget preview scaffold.
230207 AppInstance ? _widgetPreviewApp;
231208
@@ -307,7 +284,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
307284 shutdownHooks.addShutdownHook (() async {
308285 await _widgetPreviewApp? .stop ();
309286 });
310- await configureDtd ();
311287 _widgetPreviewApp = await runPreviewEnvironment (
312288 widgetPreviewScaffoldProject: rootProject.widgetPreviewScaffoldProject,
313289 );
@@ -333,31 +309,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
333309 _populatePreviewPubspec (rootProject: rootProject);
334310 }
335311
336- /// Configures the Dart Tooling Daemon connection.
337- ///
338- /// If --dtd-uri is provided, the existing DTD instance will be used. If the tool fails to
339- /// connect to this URI, it will start its own DTD instance.
340- ///
341- /// If --dtd-uri is not provided, a DTD instance managed by the tool will be started.
342- Future <void > configureDtd () async {
343- final String ? existingDtdUriStr = stringArg (FlutterGlobalOptions .kDtdUrl, global: true );
344- Uri ? existingDtdUri;
345- try {
346- if (existingDtdUriStr != null ) {
347- existingDtdUri = Uri .parse (existingDtdUriStr);
348- }
349- } on FormatException {
350- logger.printWarning ('Failed to parse value of --dtd-uri: $existingDtdUriStr .' );
351- }
352- if (existingDtdUri == null ) {
353- logger.printTrace ('Launching a fresh DTD instance...' );
354- await _dtdService.launchAndConnect ();
355- } else {
356- logger.printTrace ('Connecting to existing DTD instance at: $existingDtdUri ...' );
357- await _dtdService.connect (dtdWsUri: existingDtdUri);
358- }
359- }
360-
361312 /// Builds the application binary for the widget preview scaffold the first
362313 /// time the widget preview command is run.
363314 ///
@@ -506,12 +457,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
506457 BuildMode .debug,
507458 null ,
508459 treeShakeIcons: false ,
509- // Provide the DTD connection information directly to the preview scaffold.
510- // This could, in theory, be provided via a follow up call to a service extension
511- // registered by the preview scaffold, but there's some uncertainty around how service
512- // extensions will work with Flutter web embedded in VSCode without a Chrome debugger
513- // connection.
514- dartDefines: < String > ['$kWidgetPreviewDtdUriEnvVar =${_dtdService .dtdUri }' ],
515460 extraFrontEndOptions:
516461 isWeb ? < String > ['--dartdevc-canary' , '--dartdevc-module-format=ddc' ] : null ,
517462 packageConfigPath: widgetPreviewScaffoldProject.packageConfig.path,
@@ -654,7 +599,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
654599 if (offline) '--offline' ,
655600 '--directory' ,
656601 widgetPreviewScaffoldProject.directory.path,
657- 'dtd' ,
658602 'flutter_lints' ,
659603 'stack_trace' ,
660604 ],
0 commit comments