Skip to content

Commit 9046127

Browse files
committed
refactor to soothe my brain
1 parent f57d1c8 commit 9046127

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

  • packages/flutter_tools/lib/src/commands

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,25 +292,27 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
292292

293293
@protected
294294
void validatePrebuiltAndroidApplicationFlags() {
295+
// First, verify the build mode.
296+
if (getBuildMode() != BuildMode.release) {
297+
return;
298+
}
299+
300+
// Then, verify an Android prebuilt application is being run.
295301
final String? applicationBinary =
296302
argParser.options.containsKey(FlutterOptions.kUseApplicationBinary)
297303
? stringArg(FlutterOptions.kUseApplicationBinary)
298304
: null;
299305
if (applicationBinary != null && applicationBinary.toLowerCase().endsWith('.apk')) {
300-
final BuildMode buildMode = getBuildMode();
301-
if (buildMode == BuildMode.release) {
302-
final Iterable<String> intentFlags = AndroidEngineCliFlags.allFlags.where(
303-
(String flag) =>
304-
argParser.options.containsKey(flag) && argResults?.wasParsed(flag) == true,
305-
);
306+
final Iterable<String> intentFlags = AndroidEngineCliFlags.allFlags.where(
307+
(String flag) => argParser.options.containsKey(flag) && argResults?.wasParsed(flag) == true,
308+
);
306309

307-
if (intentFlags.isNotEmpty) {
308-
throwToolExit(
309-
'Running a prebuilt APK with --${FlutterOptions.kUseApplicationBinary} in release mode with flags used to configure the Flutter Android engine '
310-
'(${intentFlags.map((String flag) => '--$flag').join(', ')}) is no longer supported. Define the required flags via the Android manifest instead. See '
311-
'https://docs.flutter.dev/release/breaking-changes/restrict-command-line-flags-prebuilt-android-release-binaries for more details.',
312-
);
313-
}
310+
if (intentFlags.isNotEmpty) {
311+
throwToolExit(
312+
'Running a prebuilt APK with --${FlutterOptions.kUseApplicationBinary} in release mode with flags used to configure the Flutter Android engine '
313+
'(${intentFlags.map((String flag) => '--$flag').join(', ')}) is no longer supported. Define the required flags via the Android manifest instead. See '
314+
'https://docs.flutter.dev/release/breaking-changes/restrict-command-line-flags-prebuilt-android-release-binaries for more details.',
315+
);
314316
}
315317
}
316318
}
@@ -568,8 +570,9 @@ class RunCommand extends RunCommandBase {
568570

569571
@override
570572
Future<void> validateCommand() async {
571-
// Validate that prebuilt applications use engine configuration flags legally.
572573
if (runningWithPrebuiltApplication) {
574+
// For Android prebuilt applications run in release mode, validate that engine configuration flags
575+
// are not passed.
573576
validatePrebuiltAndroidApplicationFlags();
574577
} else {
575578
await super.validateCommand();

0 commit comments

Comments
 (0)