You can use the custom runtime of Function Compute to write Dart functions in Function Compute. This topic describes how to deploy and invoke a Dart function. You can modify the Dart sample code as needed for custom development.


  1. Run the following command to initialize a project:
    s init fc-custom-dart-event -d fc-custom-dart-event
  2. Run the following command to go to the project directory:
    cd fc-custom-dart-event
  3. Optional: Modify the sample code as needed for custom development.
  4. Run the following command to deploy the project:
    s deploy -y
    Sample command output:
    [2022-01-26 09:12:31] [INFO] [S-CLI] - Start the pre-action
    [2022-01-26 09:12:31] [INFO] [S-CLI] - Action: make build
    docker run --rm -it -v $(pwd):/tmp google/dart:2.8.4 bash -c "export PUB_HOSTED_URL= && cd tmp/code && dart2native index.dart && mv index.exe bootstrap"
    Unable to find image 'google/dart:2.8.4' locally
    2.8.4: Pulling from google/dart
    291bafe4382e: Pull complete
    0cbc81b3bc90: Pull complete
    Digest: sha256:0ddfc141f0f03b41822ebf6b7245f5fbfcdea89be08f7617f49a7b01a157****
    Status: Downloaded newer image for google/dart:2.8.4
    Generated: /tmp/code/index.exe
    chmod +x code/bootstrap
    [2022-01-26 09:13:23] [INFO] [S-CLI] - End the pre-action
     Checking Service, Function (2.19s)
     Creating Service, Function (27.94s)
    Tips for next step
    * Display information of the deployed resource: s info
    * Display metrics: s metrics
    * Display logs: s logs
    * Invoke remote function: s invoke
    * Remove Service: s remove service
    * Remove Function: s remove function
    * Remove Trigger: s remove trigger
    * Remove CustomDomain: s remove domain
      region:   cn-hangzhou
        name: hello-world-service
        name:       dartEventFunc
        runtime:    custom
        handler:    index.handler
        memorySize: 1024
        timeout:    60
  5. Run the following command to remotely invoke the function:
    s invoke -e "hello"
    Sample command output:
    ========= FC invoke Logs begin =========
    FC Initialize Start RequestId: a8732093-72c6-4c24-97b5-bd17f0dd****
    FC Initialize End RequestId: a8732093-72c6-4c24-97b5-bd17f0dd****
    FC Invoke Start RequestId: a8732093-72c6-4c24-97b5-bd17f0dd****
    FC Invoke End RequestId: a8732093-72c6-4c24-97b5-bd17f0dd****
    Duration: 0.94 ms, Billed Duration: 1 ms, Memory Size: 1024 MB, Max Memory Used: 17.70 MB
    ========= FC invoke Logs end =========
    FC Invoke Result:
    End of method: invoke