Cloud Functions enables serverless computing through Function as a Service (FaaS) capabilities to simplify app development and O&M. This helps you implement functions more simply and build service capabilities more quickly. The following describes how to integrate Huawei's AppGallery Connect Cloud Function service in Flutter.
We will create a basic new project as an example but of course you could make use of a project you already have thats using flutter!
Download the Flutter SDK package and decompress the package to any directory.
Download the Flutter and Dart plugins in Android Studio.
Create an Android app in AppGallery Connect and enable Cloud Functions for it as detailed in this guide.
Now we can go ahead and create a cloud function as you require it use this guide to help understand what can be done.
Once your happy with your function (in this instance it might just be as simple as returning a hello world statement for testing) you can go ahead and create a HTTP trigger that will trigger the function.
Next create your flutter project in android studio (or open your existing project if you already have one!).
Download your agconnect-services.json file from the AppGallery Connect console and add it into your project under the 'app' directory
Within the project level build.gradle file make sure to include the huawei maven repo and add the agcp package as a dependency.
Next in your app level build.gradle apply the agconnect plugin as so:
Then in your pubspec.yaml file add the Cloud Function SDK dependency.
The below code is an example of how you can call a simple cloud function and get the result returned.
Where test-\$latest is the HTTP trigger identifier.