diff --git a/packages/patrol_cli/CHANGELOG.md b/packages/patrol_cli/CHANGELOG.md index d199264df..8072712a5 100644 --- a/packages/patrol_cli/CHANGELOG.md +++ b/packages/patrol_cli/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased + +- Add android product flavor to dart-define. (#2425) + ## 3.4.0 - Add support for the `patrol_log` package. (#2387) diff --git a/packages/patrol_cli/lib/src/crossplatform/app_options.dart b/packages/patrol_cli/lib/src/crossplatform/app_options.dart index dfbc7e6ca..342ecaac7 100644 --- a/packages/patrol_cli/lib/src/crossplatform/app_options.dart +++ b/packages/patrol_cli/lib/src/crossplatform/app_options.dart @@ -115,14 +115,22 @@ class AndroidAppOptions { final target = '-Ptarget=${flutter.target}'; cmd.add(target); + // Create modifiable Map + final effectiveDartDefines = Map.of(flutter.dartDefines); + + // Add flavor to dart defines + if (flutter.flavor case final flavor?) { + effectiveDartDefines['FLUTTER_APP_FLAVOR'] = flavor; + } + // Add Dart defines encoded in base64 - if (flutter.dartDefines.isNotEmpty) { + if (effectiveDartDefines.isNotEmpty) { final dartDefinesString = StringBuffer(); - for (var i = 0; i < flutter.dartDefines.length; i++) { - final entry = flutter.dartDefines.entries.elementAt(i); + for (var i = 0; i < effectiveDartDefines.length; i++) { + final entry = effectiveDartDefines.entries.elementAt(i); final pair = utf8.encode('${entry.key}=${entry.value}'); dartDefinesString.write(base64Encode(pair)); - if (i != flutter.dartDefines.length - 1) { + if (i != effectiveDartDefines.length - 1) { dartDefinesString.write(','); } } diff --git a/packages/patrol_cli/test/crossplatform/app_options_test.dart b/packages/patrol_cli/test/crossplatform/app_options_test.dart index f30376a58..377753ce3 100644 --- a/packages/patrol_cli/test/crossplatform/app_options_test.dart +++ b/packages/patrol_cli/test/crossplatform/app_options_test.dart @@ -101,7 +101,7 @@ void main() { r'.\gradlew.bat', ':app:assembleDevReleaseAndroidTest', r'-Ptarget=C:\Users\john\app\integration_test\app_test.dart', - '-Pdart-defines=RU1BSUw9dXNlckBleGFtcGxlLmNvbQ==,UEFTU1dPUkQ9bnk0bmNhdA==,Zm9vPWJhcg==', + '-Pdart-defines=RU1BSUw9dXNlckBleGFtcGxlLmNvbQ==,UEFTU1dPUkQ9bnk0bmNhdA==,Zm9vPWJhcg==,RkxVVFRFUl9BUFBfRkxBVk9SPWRldg==', '-Papp-server-port=1', '-Ptest-server-port=2', ]), @@ -131,7 +131,7 @@ void main() { './gradlew', ':app:assembleDevDebugAndroidTest', '-Ptarget=/Users/john/app/integration_test/app_test.dart', - '-Pdart-defines=RU1BSUw9dXNlckBleGFtcGxlLmNvbQ==,UEFTU1dPUkQ9bnk0bmNhdA==,Zm9vPWJhcg==', + '-Pdart-defines=RU1BSUw9dXNlckBleGFtcGxlLmNvbQ==,UEFTU1dPUkQ9bnk0bmNhdA==,Zm9vPWJhcg==,RkxVVFRFUl9BUFBfRkxBVk9SPWRldg==', '-Papp-server-port=1', '-Ptest-server-port=2', ]),