Firebase 如何在颤振中将RemoteConfigValue转换为映射

Firebase 如何在颤振中将RemoteConfigValue转换为映射,firebase,flutter,dart,firebase-remote-config,Firebase,Flutter,Dart,Firebase Remote Config,我想将RemoteConfigValue转换为flatterMap,因为我正在使用Firebase远程配置集JSON数据作为Firebase控制台中的值 我没有得到任何函数,它给了我JSON/Map值,而不是RemoteConfigValue final RemoteConfig remoteConfig = await RemoteConfig.instance; remoteConfig.setDefaults(<String, dynamic>{}); try { awai

我想将
RemoteConfigValue
转换为flatter
Map
,因为我正在使用Firebase远程配置集
JSON
数据作为Firebase控制台中的值

我没有得到任何函数,它给了我JSON/Map值,而不是RemoteConfigValue

final RemoteConfig remoteConfig = await RemoteConfig.instance;
remoteConfig.setDefaults(<String, dynamic>{});
try {
  await remoteConfig.fetch(expiration: const Duration(seconds: 0));
  await remoteConfig.activateFetched();

  print(remoteConfig.getValue("MyKey"));

} on FetchThrottledException catch (exception) {
  print(exception.toString());
} catch (exception) {
  print(exception.toString());
}
final-RemoteConfig-RemoteConfig=wait-RemoteConfig.instance;
remoteConfig.setDefaults({});
试一试{
wait remoteConfig.fetch(过期时间:const Duration(秒数:0));
等待remoteConfig.activateFetched();
打印(remoteConfig.getValue(“MyKey”);
}在获取ThrottleException捕获时(异常){
打印(exception.toString());
}捕获(例外){
打印(exception.toString());
}
我想出来了-

步骤1:从
RemoteConfigValue
中获取字符串值,如
remoteConfig.getString(“UAE”)
this或
remoteConfig.getValue(“UAE”).asString()中获取字符串值

步骤2:使用
json将该字符串值转换为
Map
。解码

例如:

Map<String, dynamic> mapValues = json.decode(remoteConfig.getValue("MyKey").asString());      
print(mapValues["countryName"]);
Map-mapValues=json.decode(remoteConfig.getValue(“MyKey”).asString());
打印(mapValues[“countryName”]);