Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add android flavor to dartDefines. #2425

Merged
merged 7 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/patrol_cli/lib/src/crossplatform/app_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,22 @@ class AndroidAppOptions {
final target = '-Ptarget=${flutter.target}';
cmd.add(target);

// Create modifiable Map
final effectiveDartDefines = Map<String, String>.of(flutter.dartDefines);

// Add flavor to dart defines
if (flutter.flavor != null) {
effectiveDartDefines['FLUTTER_APP_FLAVOR'] = flutter.flavor!;
}
GChanathip marked this conversation as resolved.
Show resolved Hide resolved

// 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(',');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]),
Expand Down Expand Up @@ -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',
]),
Expand Down
Loading