[英]How to integrate remote config to a flutter app?
我必须将 firebase 远程配置集成到我的 flutter 应用程序中。 从各个站点的搜索中,我找不到完整的解决方案。
class RemoteConfigurartion{
Future<RemoteConfig> setupRemoteConfig() async {
String value =null;
final RemoteConfig remoteConfig = await RemoteConfig.instance;
remoteConfig.setConfigSettings(RemoteConfigSettings(debugMode: false));
remoteConfig.setDefaults(<String, dynamic>{
'riddle': "off",
});
try {
// Using default duration to force fetching from remote server.
await remoteConfig.fetch(expiration: const Duration(seconds: 0));
await remoteConfig.activateFetched();
} on FetchThrottledException catch (exception) {
// Fetch throttled.
print(exception);
} catch (exception) {
print(
'Unable to fetch remote config. Cached or default values will be '
'used');
}
return remoteConfig;
}
}
这是我已经发现的。 这是我得到的结果:
在通道插件上找不到方法 RemoteConfig#instance 的实现。flutter.io/firebase_remote_config
但是我已经在 pubspec.yaml 和 android gradle 文件夹中添加了所有插件
谁能帮我找到一个将远程配置集成到 flutter 应用程序的完整解决方案?
确保firebase_core已初始化,对于 Android,google-services.json 应位于app
文件夹中。 除此之外,您的代码似乎没有任何问题。 您可能在设置过程中错过了一些步骤。
如果您刚刚添加了插件,最好使用重新启动而不是热重载来运行应用程序,以确保所有最近添加的插件都包含在构建中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.