简体   繁体   English

如何将远程配置集成到 flutter 应用程序?

[英]How to integrate remote config to a flutter app?

I have to integrate firebase remote config to my flutter app.我必须将 firebase 远程配置集成到我的 flutter 应用程序中。 From the searches in various sites, I couldn't find the complete solution.从各个站点的搜索中,我找不到完整的解决方案。

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;
  }
}

This is what I found already.这是我已经发现的。 This the result I'm getting:这是我得到的结果:

No implementation found for method RemoteConfig#instance on channel plugins.flutter.io/firebase_remote_config在通道插件上找不到方法 RemoteConfig#instance 的实现。flutter.io/firebase_remote_config

But I have added all the plugins in the pubspec.yaml and in android gradle folder但是我已经在 pubspec.yaml 和 android gradle 文件夹中添加了所有插件

Can anyone help me to find out a complete solution to integrate remote config to a flutter app?谁能帮我找到一个将远程配置集成到 flutter 应用程序的完整解决方案?

Make sure that firebase_core is initialized, and for Android, google-services.json should be in the app folder.确保firebase_core已初始化,对于 Android,google-services.json 应位于app文件夹中。 Aside from that, there doesn't seem to be any issues on your code.除此之外,您的代码似乎没有任何问题。 You might've missed some steps during set up.您可能在设置过程中错过了一些步骤。

If you've just added the plugins, it's best to run the app using restart instead of hot reload to ensure that all recently added plugins is included in the build.如果您刚刚添加了插件,最好使用重新启动而不是热重载来运行应用程序,以确保所有最近添加的插件都包含在构建中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM