Skip to content

Commit f02cfd4

Browse files
Support the --no-devtools flag in "flutter run --machine" (#113414)
1 parent e23a683 commit f02cfd4

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

packages/flutter_tools/lib/src/commands/daemon.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ class AppDomain extends Domain {
502502
String? isolateFilter,
503503
bool machine = true,
504504
String? userIdentifier,
505+
bool enableDevTools = true,
505506
}) async {
506507
if (!await device.supportsRuntimeMode(options.buildInfo.mode)) {
507508
throw Exception(
@@ -574,7 +575,7 @@ class AppDomain extends Domain {
574575
return runner.run(
575576
connectionInfoCompleter: connectionInfoCompleter,
576577
appStartedCompleter: appStartedCompleter,
577-
enableDevTools: true,
578+
enableDevTools: enableDevTools,
578579
route: route,
579580
);
580581
},

packages/flutter_tools/lib/src/commands/run.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ class RunCommand extends RunCommandBase {
606606
ipv6: ipv6 ?? false,
607607
multidexEnabled: boolArgDeprecated('multidex'),
608608
userIdentifier: userIdentifier,
609+
enableDevTools: boolArgDeprecated(FlutterCommand.kEnableDevTools),
609610
);
610611
} on Exception catch (error) {
611612
throwToolExit(error.toString());

packages/flutter_tools/test/commands.shard/hermetic/run_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,34 @@ void main() {
523523
Stdio: () => FakeStdio(),
524524
Logger: () => AppRunLogger(parent: BufferLogger.test()),
525525
});
526+
527+
testUsingContext('can disable devtools with --no-devtools', () async {
528+
final DaemonCapturingRunCommand command = DaemonCapturingRunCommand();
529+
final FakeDevice device = FakeDevice();
530+
testDeviceManager.devices = <Device>[device];
531+
532+
await expectLater(
533+
() => createTestCommandRunner(command).run(<String>[
534+
'run',
535+
'--no-pub',
536+
'--no-devtools',
537+
'--machine',
538+
'-d',
539+
device.id,
540+
]),
541+
throwsToolExit(),
542+
);
543+
expect(command.appDomain.enableDevTools, isFalse);
544+
}, overrides: <Type, Generator>{
545+
Artifacts: () => artifacts,
546+
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
547+
DeviceManager: () => testDeviceManager,
548+
FileSystem: () => fs,
549+
ProcessManager: () => FakeProcessManager.any(),
550+
Usage: () => usage,
551+
Stdio: () => FakeStdio(),
552+
Logger: () => AppRunLogger(parent: BufferLogger.test()),
553+
});
526554
});
527555
});
528556

@@ -1066,6 +1094,7 @@ class CapturingAppDomain extends AppDomain {
10661094

10671095
bool? multidexEnabled;
10681096
String? userIdentifier;
1097+
bool? enableDevTools;
10691098

10701099
@override
10711100
Future<AppInstance> startApp(
@@ -1085,9 +1114,11 @@ class CapturingAppDomain extends AppDomain {
10851114
String? isolateFilter,
10861115
bool machine = true,
10871116
String? userIdentifier,
1117+
bool enableDevTools = true,
10881118
}) async {
10891119
this.multidexEnabled = multidexEnabled;
10901120
this.userIdentifier = userIdentifier;
1121+
this.enableDevTools = enableDevTools;
10911122
throwToolExit('');
10921123
}
10931124
}

0 commit comments

Comments
 (0)