Skip to content

Commit 9af633c

Browse files
committed
refactor(remote_config): move params check logic out of the meethod channel
1 parent 54b2a1e commit 9af633c

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

packages/firebase_remote_config/firebase_remote_config/lib/src/remote_config.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
133133

134134
/// Sets the default parameter values for the current instance.
135135
Future<void> setDefaults(Map<String, dynamic> defaultParameters) {
136+
defaultParameters.values.forEach(_checkIsSupportedType);
136137
return _delegate.setDefaults(defaultParameters);
137138
}
139+
140+
void _checkIsSupportedType(dynamic value) {
141+
if (value is! bool && value is! num && value is! String) {
142+
throw Exception(
143+
'Non-primitive types are not supported as config values. '
144+
"If you're trying to pass a json object – convert it to string beforehand",
145+
);
146+
}
147+
}
138148
}

packages/firebase_remote_config/firebase_remote_config_platform_interface/lib/src/method_channel/method_channel_firebase_remote_config.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ class MethodChannelFirebaseRemoteConfig extends FirebaseRemoteConfigPlatform {
222222

223223
@override
224224
Future<void> setDefaults(Map<String, dynamic> defaultParameters) async {
225-
defaultParameters.values.forEach(_checkIsSupportedType);
226-
227225
try {
228226
await channel.invokeMethod('RemoteConfig#setDefaults', <String, dynamic>{
229227
'appName': app.name,
@@ -287,13 +285,4 @@ class MethodChannelFirebaseRemoteConfig extends FirebaseRemoteConfigPlatform {
287285
return ValueSource.valueStatic;
288286
}
289287
}
290-
291-
void _checkIsSupportedType(dynamic value) {
292-
if (value is! bool && value is! num && value is! String) {
293-
throw Exception(
294-
'Non-primitive types are not supported as config values. '
295-
"If you're trying to pass a json object – convert it to string beforehand",
296-
);
297-
}
298-
}
299288
}

0 commit comments

Comments
 (0)