Skip to content

Commit

Permalink
fix: set growable: false for unmutable lists
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Mar 27, 2022
1 parent 5dfe71f commit 9915b71
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions lib/src/core/consumed_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class ConsumedThing implements scripting_api.ConsumedThing {
.allMatches(Uri.decodeFull(href))
.map((e) => e.group(1))
.whereType<String>()
.toList();
.toList(growable: false);
}

String _resolveUriVariables(InteractionAffordance interactionAffordance,
Expand Down Expand Up @@ -300,7 +300,7 @@ class ConsumedThing implements scripting_api.ConsumedThing {
void _augmentForms(InteractionAffordance interactionAffordance) {
interactionAffordance.augmentedForms = interactionAffordance.forms
.map((form) => form.augment(thingDescription))
.toList();
.toList(growable: false);
}

@override
Expand Down Expand Up @@ -390,7 +390,8 @@ class ConsumedThing implements scripting_api.ConsumedThing {

@override
Future<PropertyReadMap> readAllProperties([InteractionOptions? options]) {
final propertyNames = thingDescription.properties.keys.toList();
final propertyNames =
thingDescription.properties.keys.toList(growable: false);

return _readProperties(propertyNames, options);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/definitions/form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Form {
if (jsonOp is String) {
op = [jsonOp];
} else if (jsonOp is List<dynamic>) {
op = jsonOp.whereType<String>().toList();
op = jsonOp.whereType<String>().toList(growable: false);
}
}

Expand All @@ -102,7 +102,7 @@ class Form {
if (jsonSecurity is String) {
security = [jsonSecurity];
} else if (jsonSecurity is List<dynamic>) {
security = jsonSecurity.whereType<String>().toList();
security = jsonSecurity.whereType<String>().toList(growable: false);
}
}

Expand All @@ -111,7 +111,7 @@ class Form {
if (jsonScopes is String) {
scopes = [jsonScopes];
} else if (jsonScopes is List<dynamic>) {
scopes = jsonScopes.whereType<String>().toList();
scopes = jsonScopes.whereType<String>().toList(growable: false);
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/definitions/security/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ List<String> parseSecurityJson(
if (jsonLdType is String) {
securityScheme.jsonLdType = [jsonLdType];
} else if (jsonLdType is List<dynamic>) {
securityScheme.jsonLdType = jsonLdType.whereType<String>().toList();
securityScheme.jsonLdType =
jsonLdType.whereType<String>().toList(growable: false);
}

return parsedJsonFields;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/definitions/security/oauth2_security_scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class OAuth2SecurityScheme extends SecurityScheme {
scopes = [jsonScopes];
_parsedJsonFields.add("scopes");
} else if (jsonScopes is List<dynamic>) {
scopes = jsonScopes.whereType<String>().toList();
scopes = jsonScopes.whereType<String>().toList(growable: false);
_parsedJsonFields.add("scopes");
}

Expand Down

0 comments on commit 9915b71

Please sign in to comment.