Skip to content

Commit 64ebcf7

Browse files
committed
fix: --dart-define not read properly (#172)
1 parent 1249071 commit 64ebcf7

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

starport_template/ios/fastlane/Fastfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ platform :ios do
4343
)
4444

4545
increment_build_number(
46-
build_number: ENV["$GITHUB_RUN_NUMBER"]
46+
build_number: ENV["GITHUB_RUN_NUMBER"]
4747
)
4848

4949
build_app(

starport_template/lib/utils/base_env.dart

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,30 @@ class BaseEnv {
2727
final String baseApiUrl;
2828
}
2929

30+
// DO NOT USE String.fromEnvironment without 'const'!!!
31+
// https://github.com/flutter/flutter/issues/55870#issuecomment-620776138
3032
String get envLcdPort => const String.fromEnvironment('LCD_PORT', defaultValue: '1317');
3133

34+
// DO NOT USE String.fromEnvironment without 'const'!!!
35+
// https://github.com/flutter/flutter/issues/55870#issuecomment-620776138
3236
String get envGrpcPort => const String.fromEnvironment('GRPC_PORT', defaultValue: '9090');
3337

34-
String get envLcdUrl => String.fromEnvironment(
35-
'LCD_URL',
36-
defaultValue: Platform.isAndroid ? 'http://10.0.2.2' : 'http://localhost',
37-
);
38+
String get envLcdUrl {
39+
// DO NOT USE String.fromEnvironment without 'const'!!!
40+
// https://github.com/flutter/flutter/issues/55870#issuecomment-620776138
41+
const result = String.fromEnvironment('LCD_URL');
42+
if (result.isEmpty) {
43+
return Platform.isAndroid ? 'http://10.0.2.2' : 'http://localhost';
44+
}
45+
return result;
46+
}
3847

39-
String get envGrpcUrl => String.fromEnvironment(
40-
'GRPC_URL',
41-
defaultValue: Platform.isAndroid ? 'http://10.0.2.2' : 'http://localhost',
42-
);
48+
String get envGrpcUrl {
49+
// DO NOT USE String.fromEnvironment without 'const'!!!
50+
// https://github.com/flutter/flutter/issues/55870#issuecomment-620776138
51+
const result = String.fromEnvironment('GRPC_URL');
52+
if (result.isEmpty) {
53+
return Platform.isAndroid ? 'http://10.0.2.2' : 'http://localhost';
54+
}
55+
return result;
56+
}

0 commit comments

Comments
 (0)