flutterfirebasefirebase-remote-config

Error trying to run a Flutter WEB app, using Firebase Remote Config


I have a Flutter app, using Firebase, running just fine on iOS and Android (emulators and physical devices).

I'm trying to compile and run it for the web, and I get an error when trying to use Firebase services (specifically ConfigRemote but I suspect it's a Firebase general issue).

This is the first time I try to compile for web, with Firebase, so my knowledge here is quite limited...

What I've done:

  1. Added a web app on the Firebase console
  2. Copied the required scripts into the body tag (index.html)
  3. Added all dependencies scripts (index.html)
     <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
     <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-firestore.js"></script>
     <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-auth.js"></script>
     <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-functions.js"></script>
     <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-storage.js"></script>
     <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-remote-config.js"></script>
     <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-messaging.js"></script>

The error I'm getting (at await ui.webOnlyInitializePlatform()):

Error: NoSuchMethodError: '<Unexpected Null Value>'
method not found
Receiver: null
Arguments: []
    at Object.throw_ [as throw] (http://localhost:64231/dart_sdk.js:5348:11)
    at Object.throwNullValueError (http://localhost:64231/dart_sdk.js:5314:15)
    at Object._notNull [as notNull] (http://localhost:64231/dart_sdk.js:5667:25)
    at new core.Duration.new (http://localhost:64231/dart_sdk.js:123963:168)
    at method_channel_firebase_remote_config.MethodChannelFirebaseRemoteConfig.new.setInitialValues (http://localhost:64231/packages/firebase_remote_config_platform_interface/src/method_channel/method_channel_firebase_remote_config.dart.lib.js:230:26)
    at Function.instanceFor (http://localhost:64231/packages/firebase_remote_config_platform_interface/src/method_channel/method_channel_firebase_remote_config.dart.lib.js:88:118)
    at firebase_remote_config.RemoteConfig.__.get [_delegate] (http://localhost:64231/packages/firebase_remote_config/firebase_remote_config.dart.lib.js:62:131)
    at firebase_remote_config.RemoteConfig.__.setConfigSettings (http://localhost:64231/packages/firebase_remote_config/firebase_remote_config.dart.lib.js:138:18)
    at _loadRemoteConfig (http://localhost:64231/packages/bla/main.dart.lib.js:299:26)
    at _loadRemoteConfig.next (<anonymous>)
    at runBody (http://localhost:64231/dart_sdk.js:39250:34)
    at Object._async [as async] (http://localhost:64231/dart_sdk.js:39281:7)
    at Object._loadRemoteConfig (http://localhost:64231/packages/bla/main.dart.lib.js:293:18)
    at main$ (http://localhost:64231/packages/bla/main.dart.lib.js:288:18)
    at main$.next (<anonymous>)
    at http://localhost:64231/dart_sdk.js:39230:33
    at _RootZone.runUnary (http://localhost:64231/dart_sdk.js:39087:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:64231/dart_sdk.js:34073:29)
    at handleValueCallback (http://localhost:64231/dart_sdk.js:34633:49)
    at Function._propagateToListeners (http://localhost:64231/dart_sdk.js:34671:17)
    at _Future.new.[_completeWithValue] (http://localhost:64231/dart_sdk.js:34513:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:64231/dart_sdk.js:34536:35)
    at Object._microtaskLoop (http://localhost:64231/dart_sdk.js:39374:13)
    at _startMicrotaskLoop (http://localhost:64231/dart_sdk.js:39380:13)
    at http://localhost:64231/dart_sdk.js:34887:9

Solution

  • Remote configs is not supported by Flutter Web https://firebase.flutter.dev

    I'll also suggest you to delete the js script from your index.html and also taking care of the condition you're expecting from Remote Config to avoid more exceptions in your code.