Skip to content

Commit

Permalink
Fixed type mismatch error on keyOperations getter
Browse files Browse the repository at this point in the history
When JWK object tries to get `keyOperations`, dart throws the error:
`type '_CompactLinkedHashSet<dynamic>' is not a subtype of type 'Set<String>?' in type cast`

Fixed it by setting particular type on calling `getTypedList`
  • Loading branch information
Samataro authored Apr 8, 2022
1 parent 22466b4 commit 8870b31
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/jwk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class JsonWebKey extends JsonObject {
///
/// Other values MAY be used.
Set<String>? get keyOperations =>
getTypedList('key_ops')?.toSet() as Set<String>?;
getTypedList<String>('key_ops')?.toSet() as Set<String>?;

/// The algorithm intended for use with the key.
String? get algorithm => this['alg'];
Expand Down Expand Up @@ -415,7 +415,7 @@ class JsonWebKey extends JsonObject {
class JsonWebKeySet extends JsonObject {
/// An array of JWK values
List<JsonWebKey> get keys =>
getTypedList('keys', factory: (v) => JsonWebKey.fromJson(v)) ?? const [];
getTypedList<JsonWebKey>('keys', factory: (v) => JsonWebKey.fromJson(v)) ?? const [];

/// Constructs a [JsonWebKeySet] from the list of [keys]
factory JsonWebKeySet.fromKeys(Iterable<JsonWebKey> keys) =>
Expand Down

0 comments on commit 8870b31

Please sign in to comment.