Skip to content

Commit

Permalink
fix(remote-config, web): getAll() API throwing runtime exception wi…
Browse files Browse the repository at this point in the history
…th incorrect cast to `List<String>` (#12602)
  • Loading branch information
russellwheatley committed Apr 9, 2024
1 parent 2cc1618 commit 70e257e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Expand Up @@ -106,9 +106,12 @@ class RemoteConfig

/// Returns all config values.
Map<String, RemoteConfigValue> getAll() {
final keys =
remote_config_interop.getAll(jsObject).dartify()! as List<String>;
final entries = keys.map<MapEntry<String, RemoteConfigValue>>(
// Return type is Map<Object?, Object?>
final map = remote_config_interop.getAll(jsObject).dartify()!
as Map<Object?, Object?>;
// Cast the map to <String, Object?> to mirror expected return type: Record<string, Value>;
final castMap = map.cast<String, Object?>();
final entries = castMap.keys.map<MapEntry<String, RemoteConfigValue>>(
(dynamic k) => MapEntry<String, RemoteConfigValue>(k, getValue(k)),
);
return Map<String, RemoteConfigValue>.fromEntries(entries);
Expand Down
Expand Up @@ -77,6 +77,11 @@ void main() {
FirebaseRemoteConfig.instance.getValue('nonexisting').source,
ValueSource.valueStatic,
);

expect(
FirebaseRemoteConfig.instance.getAll(),
isA<Map<String, RemoteConfigValue>>(),
);
},
// iOS v9.2.0 hangs on ci if `fetchAndActivate()` is used, but works locally.
// macOS skipped because it needs keychain sharing entitlement. See: https://github.com/firebase/flutterfire/issues/9538
Expand Down

0 comments on commit 70e257e

Please sign in to comment.