Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call a callable v2 Cloud Function in Flutter?

I have a Flutter app that uses cloud functions. I upgraded one function to a v2 function and it no longer works. The function cannot be found. The function logs do not show that it is being called. It is in the us-central1 region, as is the rest of the project.

final result = await FirebaseFunctions.instance.httpsCallable('addMessage').call();

Instead of addMessage I have tried the full function URL found in the firebase console, but that does not work either.

Function declaration:

exports.addMessage = onCall(async (request) => {
  //Run function
});

How do I call a v2 cloud function in flutter?

like image 563
user11015833 Avatar asked Jul 19 '26 20:07

user11015833


1 Answers

With cloud_functions version 4.1.0, it is now possible to call 2nd gen cloud functions:

FirebaseFunctions.instance
      .httpsCallableFromUrl("https://example.run.app/")
      .call({"paramter": "value"});

Note that you need to deploy the function before you can know what the URL will be. This will change in the future according to the docs:

https://cloud.google.com/functions/docs/tutorials/http#triggering_the_function

like image 195
Erfa Avatar answered Jul 22 '26 15:07

Erfa