Skip to content

Commit

Permalink
fix(core): Remove dart define (temporary)
Browse files Browse the repository at this point in the history
Removes dart defines from `AWSConfigValue` as a temporary solution to dart-lang/sdk#49245

commit-id:c75e6257
  • Loading branch information
Dillon Nys authored and dnys1 committed Jun 14, 2022
1 parent 545c9bc commit 0c09ab2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/aws_common/lib/src/config/aws_config_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ T _identity<T extends Object>(String o) => o as T;
class AWSConfigValue<T extends Object> {
const AWSConfigValue._(
this.key,
this._fromEnv,
// TODO(dnys1): Add back when https://github.com/dart-lang/sdk/issues/49245 is resolved.
// this._fromEnv,
this.defaultValue, {
T Function(String)? parse,
}) : _parse = parse ?? _identity;
Expand All @@ -34,7 +35,8 @@ class AWSConfigValue<T extends Object> {
/// should make for a single SDK operation invocation before giving up.
static const AWSConfigValue<int> maxAttempts = AWSConfigValue<int>._(
'AWS_MAX_ATTEMPTS',
String.fromEnvironment('AWS_MAX_ATTEMPTS'),
// TODO(dnys1): Add back when https://github.com/dart-lang/sdk/issues/49245 is resolved.
// String.fromEnvironment('AWS_MAX_ATTEMPTS'),
3,
parse: int.parse,
);
Expand All @@ -45,7 +47,8 @@ class AWSConfigValue<T extends Object> {
/// The default value of the configuration parameter.
final T defaultValue;

final String? _fromEnv;
// TODO(dnys1): Add back when https://github.com/dart-lang/sdk/issues/49245 is resolved.
// final String? _fromEnv;
final T Function(String) _parse;
String? get _fromPlatformEnv => lookupPlatformEnv(key);

Expand All @@ -61,10 +64,11 @@ class AWSConfigValue<T extends Object> {
} else if (fromOverride is String) {
return _parse(fromOverride);
}
final fromEnv = _fromEnv;
if (fromEnv != null && fromEnv.isNotEmpty) {
return _parse(fromEnv);
}
// TODO(dnys1): Add back when https://github.com/dart-lang/sdk/issues/49245 is resolved.
// final fromEnv = _fromEnv;
// if (fromEnv != null && fromEnv.isNotEmpty) {
// return _parse(fromEnv);
// }
final fromPlatformEnv = _fromPlatformEnv;
if (fromPlatformEnv != null && fromPlatformEnv.isNotEmpty) {
return _parse(fromPlatformEnv);
Expand Down

0 comments on commit 0c09ab2

Please sign in to comment.