cloud_functions 0.5.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 94

Cloud Functions Plugin for Flutter #

A Flutter plugin to use the Cloud Functions for Firebase API

pub package

For Flutter plugins for other Firebase products, see

Setup #

To use this plugin:

  1. Using the Firebase Console, add an Android app to your project: Follow the assistant, download the generated google-services.json file and place it inside android/app. Next, modify the android/build.gradle file and the android/app/build.gradle file to add the Google services plugin as described by the Firebase assistant. Ensure that your android/build.gradle file contains the as described here.
  2. Using the Firebase Console, add an iOS app to your project: Follow the assistant, download the generated GoogleService-Info.plist file, open ios/Runner.xcworkspace with Xcode, and within Xcode place the file inside ios/Runner. Don't follow the steps named "Add Firebase SDK" and "Add initialization code" in the Firebase assistant.
  3. Add cloud_functions as a dependency in your pubspec.yaml file.

Usage #

import 'package:cloud_functions/cloud_functions.dart';

Getting an instance of the callable function:

final HttpsCallable callable = CloudFunctions.instance.getHttpsCallable(

Calling the function:

dynamic resp = await;

Calling the function with parameters:

dynamic resp = await<String, dynamic>{

Getting Started #

See the example directory for a complete sample app using Cloud Functions for Firebase.

Issues and feedback #

Please file Flutterfire specific issues, bugs, or feature requests in our issue tracker.

Plugin issues that are not specific to Flutterfire can be filed in the Flutter issue tracker.

To contribute a change to this plugin, please review our contribution guide, and send a pull request.

0.5.0 #

  • Fix example app build failure on CI (missing AndroidX Gradle properties).
  • Change environment SDK requirement from >=2.0.0-dev.28.0 to >=2.0.0 to fix 'publishable' CI stage.

0.4.2+3 #

  • Fix for missing UserAgent.h compilation failures.

0.4.2+2 #

  • Fix method channel on darwin

0.4.2+1 #

  • Make the pedantic dev_dependency explicit.

0.4.2 #

  • Add macOS support

0.4.1+9 #

  • Depends on cloud_functions_web so that projects importing this plugin will get web support.
  • Added web implementation to the example application.

0.4.1+8 #

  • Fixes the No implementation found for method CloudFunctions#call

0.4.1+7 #

  • Update to use the platform interface to execute calls.
  • Fix timeout for Android (which had been ignoring explicit timeouts due to unit mismatch).
  • Update repository location based on platform interface refactoring.

0.4.1+6 #

  • Fix analysis failures

0.4.1+5 #

  • Remove the deprecated author: field from pubspec.yaml
  • Migrate the plugin to the pubspec platforms manifest.
  • Bump the minimum Flutter version to 1.10.0.

0.4.1+4 #

  • Updated README instructions for contributing for consistency with other Flutterfire plugins.

0.4.1+3 #

  • Remove AndroidX warning.

0.4.1+2 #

  • Update Android package name.

0.4.1+1 #

  • Update documentation to reflect new repository location.
  • Update unit tests to call TestWidgetsFlutterBinding.ensureInitialized.

0.4.1 #

  • Support for cloud functions emulators.

0.4.0+3 #

  • Update google-services Android gradle plugin to 4.3.0 in documentation and examples.

0.4.0+2 #

  • Automatically use version from pubspec.yaml when reporting usage to Firebase.

0.4.0+1 #

  • Remove reference to unused header file.

0.4.0 #

  • Removed unused parameters param from getHttpsCallable.

0.3.0+1 #

  • Update iOS dependencies to latest.

0.3.0 #

  • Update Android dependencies to latest.

0.2.0+1 #

  • Removed flaky timeout test.

0.2.0 #

  • Breaking change. Updated Dart API to replace call with getHttpsCallable.
  • Added support for timeouts.
  • Additional integration testing.

0.1.2+1 #

  • Added a driver test.

0.1.2 #

  • Specifying a version for Cloud Functions CocoaPod dependency to prevent build errors on iOS.
  • Fix on iOS when using a null region.
  • Upgrade the firebase_core dependency of the example app.

0.1.1+1 #

  • Log messages about automatic configuration of the default app are now less confusing.

0.1.1 #

  • Support for regions and multiple apps

0.1.0+1 #

  • Log a more detailed warning at build time about the previous AndroidX migration.

0.1.0 #

  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.

0.0.5 #

  • Set iOS deployment target to 8.0 (minimum supported by both Firebase SDKs and Flutter), fixes compilation errors.
  • Fixes null pointer error when callable function fails with exception (iOS).

0.0.4+1 #

  • Bump Android dependencies to latest.

0.0.4 #

  • Fixed podspec to use static_framework

0.0.3 #

  • Added missing dependency on meta package.

0.0.2 #

  • Bump Android and Firebase dependency versions.

0.0.1 #

  • The Cloud Functions for Firebase client SDKs let you call functions directly from a Firebase app. This plugin exposes this ability to Flutter apps.

    Callable functions are similar to other HTTP functions, with these additional features:

    • With callables, Firebase Authentication and FCM tokens are automatically included in requests.
    • The functions.https.onCall trigger automatically deserializes the request body and validates auth tokens.


// Copyright 2018, the Chromium project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:cloud_functions/cloud_functions.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  String _response = 'no response';
  int _responseCount = 0;

  Widget build(BuildContext context) {
    final HttpsCallable callable = CloudFunctions.instance
        .getHttpsCallable(functionName: 'repeat')
          ..timeout = const Duration(seconds: 30);
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Cloud Functions example app'),
        body: Center(
          child: Container(
            margin: const EdgeInsets.only(top: 32.0, left: 16.0, right: 16.0),
            child: Column(
              children: <Widget>[
                Text('Response $_responseCount: $_response'),
                  child: const Text('SEND REQUEST'),
                  onPressed: () async {
                    try {
                      final HttpsCallableResult result = await
                        <String, dynamic>{
                          'message': 'hello world!',
                          'count': _responseCount,
                      setState(() {
                        _response =['repeat_message'];
                        _responseCount =['repeat_count'];
                    } on CloudFunctionsException catch (e) {
                      print('caught firebase functions exception');
                    } catch (e) {
                      print('caught generic exception');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  cloud_functions: ^0.5.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:cloud_functions/cloud_functions.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jun 5, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
cloud_functions_platform_interface ^1.1.0 1.1.0
cloud_functions_web ^1.1.0 1.1.0
firebase_core ^0.4.4 0.4.5
flutter 0.0.0
meta ^1.1.6 1.1.8
Transitive dependencies
charcode 1.1.3
collection 1.14.12
firebase 7.3.0
firebase_core_platform_interface 1.0.4
firebase_core_web 0.1.1+2
flutter_web_plugins 0.0.0
http 0.12.1
http_parser 3.1.4
js 0.6.1+1
matcher 0.12.6
path 1.7.0
plugin_platform_interface 1.0.2
quiver 2.1.3
sky_engine 0.0.99
source_span 1.7.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
pedantic ^1.8.0 1.9.0
test any