cloud_functions_web 1.0.1 copy "cloud_functions_web: ^1.0.1" to clipboard
cloud_functions_web: ^1.0.1 copied to clipboard


The web implementation of cloud_functions

cloud_functions_web #

The web implementation of cloud_functions.

Usage #

Import the package #

TODO(sbeitzel) - update the versions here so that it's correct, once this package actually is an endorsed implementation of package:cloud_functions

This package is the endorsed implementation of cloud_functions for the web platform since version 0.0.1, so it gets automatically added to your dependencies by depending on cloud_functions: ^0.0.1.

No modifications to your pubspec.yaml should be required in a recent enough version of Flutter (>=1.12.13+hotfix.4):

  cloud_functions: ^0.0.1

Updating index.html #

Due to this bug in dartdevc, you will need to manually add the Firebase JavaScript file to your index.html file.

In your app directory, edit web/index.html to add the line:

        <script src=""></script>
        <script src=""></script>
        <!-- Other firebase SDKs/config here -->
        <script src="main.dart.js"></script>

Initialize Firebase #

If your app is using the "default" Firebase app (this means that you're not doing any package:firebase_core initialization yourself), you need to initialize it now, following the steps in the Firebase Web Setup docs.

Specifically, you'll want to add the following lines to your web/index.html file:

  <!-- Previously loaded Firebase SDKs -->

  <!-- ADD THIS BEFORE YOUR main.dart.js SCRIPT -->
    // TODO: Replace the following with your app's Firebase project configuration.
    // See:
    var firebaseConfig = {
      apiKey: "...",
      authDomain: "[YOUR_PROJECT]",
      databaseURL: "https://[YOUR_PROJECT]",
      projectId: "[YOUR_PROJECT]",
      storageBucket: "[YOUR_PROJECT]",
      messagingSenderId: "...",
      appId: "1:...:web:...",
      measurementId: "G-..."
    // Initialize Firebase

  <script src="main.dart.js"></script>

Using the plugin #

Once you have modified your web/index.html file you should be able to use package:cloud_functions as normal.


  • The example app in package:cloud_functions has an implementation of this instructions.