title: How to call Cloud Function from Firebase in Flutter?
body: <p>I am trying to update some values that I will enter from my Flutter app to FireStore using Cloud Functions.  Here is my code so far:</p>
  <p>This is my Cloud function (in JavaScript, <code>index.js</code>) to update a document in FireStore:</p>
  <pre><code>exports.update = functions.https.onRequest((req, res) =&gt; {
  const getNewPercentage = req.body;
  const getDocument = admin.firestore().collection('waterpercentage').doc('percentage');
  
  getDocument.get().then((doc) =&gt; {
      if(doc.exists) {
          getDocument.update({'percentage': getNewPercentage}).catch(err =&gt; {
              console.log(&quot;Error: &quot;, err);
              res.send(&quot;500&quot;);
          })
      }
  }).catch(err =&gt; {
      console.log(&quot;Error: &quot;, err)
      res.send(&quot;500&quot;);
  });
  res.send(200);
  </code></pre>
  <p>})</p>
  <p>In Flutter, here's what I tried:</p>
  <pre><code>  Future&lt;void&gt; updateWaterPercentage() async {
  HttpsCallable callable = FirebaseFunctions.instance.httpsCallable('update');
  //final results = await callable.call(&lt;dynamic, int&gt;{'percentage' : percentage.round()});
  log(&quot;Calling percentage here: &quot;);
  log(percentage.round().toString());
  dynamic resp = await callable.call(&lt;double, dynamic&gt; {
    percentage : percentage.round(),
  });
  </code></pre>
  <p>When I call updateWaterPercentage() from a Button in Flutter, the data doesn't get updated in FireStore.  I also tried using:</p>
  <pre><code>CloudFunctions.instance.call(
                      functionName: &quot;update&quot;,
                      parameters: {
                        &quot;percentage&quot;: percentage.round(),
                      }
                    );
  </code></pre>
  <p>However, even though I imported <code>'package:cloud_functions/cloud_functions.dart';</code> on top, Flutter doesn't recognize <code>CloudFunctions</code>.  How can I get the code to call <code>update</code> that takes in a parameter to correctly update a value in Firestore?</p>