Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions docs/ff-concepts/adding-customization/cloud-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
slug: /concepts/custom-code/cloud-functions
title: Cloud Functions
description: Learn how to use Cloud Functions in your FlutterFlow app for serverless backend functionality.
tags: [FlutterFlow, Cloud Functions, Serverless, Integration]
tags: [Cloud Functions, Serverless, Integration]
sidebar_position: 6
keywords: [FlutterFlow, Cloud Functions, Serverless, Integration]
---

# Cloud Functions

[Cloud Functions](https://firebase.google.com/docs/functions) allows you to run backend code in response to events triggered by Firebase features and HTTPS requests. For example, you want to automatically send a welcome email to users when they sign up for your app. You can do this using a Cloud Function that triggers on Firebase Authentication's user creation event.
[**Cloud Functions**](https://firebase.google.com/docs/functions) allows you to run backend code in response to events triggered by Firebase features and HTTPS requests. For example, you want to automatically send a welcome email to users when they sign up for your app. You can do this using a Cloud Function that triggers on Firebase Authentication's user creation event.

We allow you to write and deploy Firebase Cloud Functions directly within the platform. With an integrated code editor, writing JavaScript cloud functions is quick and user-friendly. Each function has customizable boilerplate settings, including pre-configured essentials like memory, region, and timeout.

:::note
You can find some interesting use cases [*here*](https://firebase.google.com/docs/functions/use-cases).
Read up on some interesting use cases of
[**Cloud Functions**](https://firebase.google.com/docs/functions/use-cases).
:::

## Adding Cloud Functions
Expand All @@ -40,7 +41,8 @@ Here are the step-by-step instructions to build such an example:
:::info[Before you Begin]

* Make sure the project is on Blaze plan on Firebase.
* Completed all steps in the [Firebase Setup](/data-and-backend/firebase/firebase-setup).
* Completed all steps in the
[**Firebase Setup**](../../ff-integrations/firebase/connect-to-firebase-setup.md).
:::

### 1. Add page state variables
Expand All @@ -50,6 +52,8 @@ For this example, you'll need to set up two [page state variables](/data-and-bac
1. **generatingImage (*****Type: Boolean*****)**: This is used to control the visibility of a
loading indicator during the logo creation process. Its value is set to *True* before initiating the API call and switched to *False* once the logo generation is complete.
5. **logoImage (*****Type: ImagePath*****)**: This is used to hold the generated logo image. After a successful API call, the retrieved image URL is stored here, allowing the logo to be displayed in the Image widget.

<p></p>
![img_6.png](imgs%2Fimg_6.png)

### 2. Build a page
Expand All @@ -69,16 +73,18 @@ Few things to note here:

To create and deploy a *Cloud Function* :

1. Click on the **Cloud Functions** from the [*Navigation Menu*]
(/getting-started/ui-builder/navigation-menu) (left side of your screen).
5. Click **+ Add**. This will add the default newCloudFunction*.*
1. Click on the **Cloud Functions** from the
[**Navigation Menu**](../../../docs/intro/ff-ui/builder.md#navigation-menu) (left side of your
screen).
5. Click **+ Add**. This will add the default `newCloudFunction`.
8. Set the **Cloud Function Name**.

#### Boilerplate Settings

On the right side, you can configure the following Boilerplate Settings:
1. **Memory Allocation**: You can specify the amount of memory your function should have when
it's executed based on its complexity and needs. This setting is crucial as it influences the function's performance and the cost of running it. More memory can enhance performance for intensive tasks but also increase costs.

5. **Timeout (s)**: This refers to the maximum amount of time, in seconds, that a function is allowed to run before it is automatically terminated. If your function takes longer to execute, increasing the timeout setting may be necessary. However, be aware that longer timeouts can incur higher costs since billing is based on execution time.
8. **Require Authentication**: Turn on this setting if you want users to be authenticated to execute this cloud function.
11. **Cloud Function Region**: This determines the geographical location of the servers where your functions are hosted and executed. Ideally, you should keep this same as your *Default GCP resource location* and the Cloud Function Region specified in the Firebase Advanced Settings.
Expand All @@ -92,6 +98,7 @@ by configuring the input and output.

1. To receive output from a Cloud Function, enable the **Return Value** and choose an
appropriate Type for the output, like 'String' for text. For this example, set it to *ImagePath* to get the URL of the generated logo.

5. To input data: Click **+ Add parameters**. **Name** the parameter, select its **Type**, choose single or multiple items (**Is List** option), and uncheck **Nullable** if the value can be null. For this example, add a parameter 'prompt' with *Type* set to *String*.
8. When using [Custom Data Types](/data-and-backend/custom-data-types), Cloud Function expects JSON, matching each field in the Data Type to a key-value pair in the JSON. If the Data Type is a list, the function expects a list of JSONs. For example, for a custom data type named 'Person' with fields 'Name' and 'Age,' the function should return:

Expand Down Expand Up @@ -125,6 +132,7 @@ For a list, the function should return:
#### To deploy
1. Click the `[</>]` icon to view the boilerplate code; a popup will open with the updated
code, and then click **`</> Copy to Editor`**. **Tip**: To see if you are able to deploy the cloud function (before adding your own code), proceed directly with steps 8 and 9.

2. Inside the code editor, add the cloud function code. **Tip**: You can copy the boilerplate code
to [ChatGPT](https://chat.openai.com/) and ask it to write the desired code based on that.
3. Click **Save Cloud Function**.
Expand Down
3 changes: 2 additions & 1 deletion docs/ff-concepts/adding-customization/custom-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ Future setStatusbarColor() async {
}
```

2. Now click on **Custom Functions** from the [*Navigation Menu*](/getting-started/ui-builder/navigation-menu) (left side of your screen) and open the **Custom Files > main.dart**.
2. Now click on **Custom Functions** from the
[**Navigation Menu**](../../../docs/intro/ff-ui/builder.md#navigation-menu) and open the **Custom Files > main.dart**.
5. Determine where to place the code (i.e., **Initial Action** or **Final Action**), click the **+** button, and select the custom action.
8. Click **Save**.

Expand Down
8 changes: 5 additions & 3 deletions docs/ff-concepts/state-management/state-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: State Management
description: An overview of state management in FlutterFlow
---

State management is a crucial concept focused on maintaining and controlling the *state* of an application. Simply put, it involves monitoring the changes within your app and updating the user interface to reflect these changes.
State management is a crucial concept focused on maintaining and controlling the **state** of an application. Simply put, it involves monitoring the changes within your app and updating the user interface to reflect these changes.

You can think of the UI as a function of your state variables, where changes in these variables directly influence what the UI displays.

Expand All @@ -28,8 +28,10 @@ You can learn more about state management from this video:
<p></p>

:::tip
To learn more about state management in FlutterFlow, read up on [**Variables**](#) and how [**Page
State**](#), or
To learn more about state management in FlutterFlow, read up on
[**Variables**](../../resources/data-representation/overview.md#variable) and how
[**Page
State**](../../resources/ui-building-blocks/pages/page-lifecycle.md#page-state), or
[**Component State**](#) or [**App State variables**](#) are modified in FlutterFlow.
:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ keywords: [FlutterFlow, Anonymous Login, Authentication, Firebase]

Before getting started with this section:

- Complete [**Firebase Setup**](#)
- Complete [**Initial Setup**](initial-setup.md) required for authentication.

- Complete [**Firebase Setup**](.././../../firebase/connect-to-firebase-setup.md)
- Complete [**Initial Setup**](auth-initial-setup) required for authentication.
- Learn more about the concepts
of [**Anonymous Authentication**](docs/Integrations/Authentication/Concepts/authentication-approaches.md)
of [**Anonymous Authentication**](authentication-approaches.md)
:::

## Enable Anonymous Authentication in Firebase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords: [FlutterFlow, Apple Login, Authentication, Firebase]

Apple Sign-In allows users to authenticate using their Apple Accounts.

:::warning
:::warning[Support]

Apple sign-in functionality is only supported for iOS.

Expand Down Expand Up @@ -49,11 +49,13 @@ Apple sign-in functionality is only supported for iOS.

Before getting started with this section:

1. Complete [**Firebase Setup**](#).
2. Complete [**Initial setup**](initial-setup.md) required for authentication.
1. Complete [**Firebase Setup**](../../../firebase/connect-to-firebase-setup.md).
2. Complete [**Initial setup**](auth-initial-setup) required for authentication.
3. Created an [**Apple account**](https://appleid.apple.com/account?appId=632&returnUrl=https%3A%2F%2Fdeveloper.apple.com%2Faccount%2F).
4. [**Purchased an Apple Developer membership**](https://developer.apple.com/programs/enroll/). Please see [**this link**](https://developer.apple.com/programs/) for more details on the Apple Developer program and how to sign up.
5. Apple sign-In can not be tested in Run Mode. You will need to test it on a real device or emulator.
4. [**Purchased an Apple Developer membership**](https://developer.apple.com/programs/enroll/).
Read more about the [**Apple Developer Program**](https://developer.apple.com/programs/) and how to sign up.
5. Apple sign-In can not be tested in Run Mode. You will need to test it on a real device or
emulator. Try with Local Run!
:::

## Adding Apple sign-in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
slug: /integrations/authentication/firebase/initial-setup
title: Initial Setup
description: Learn how to perform the initial setup for Firebase authentication in your FlutterFlow app.
tags: [FlutterFlow, Initial Setup, Authentication, Firebase]
tags: [Initial Setup, Authentication, Firebase]
sidebar_position: 0
keywords: [FlutterFlow, Initial Setup, Authentication, Firebase]
---
Expand Down Expand Up @@ -49,12 +49,11 @@ The 'users' collection stores the information for authenticated users.

:::tip[Skip if...]
You have already enabled 'Create User Collection' while creating a new
project with a Firebase setup.

project with [Firebase Setup](../../../firebase/connect-to-firebase-setup.md).
:::

1. Click on the Firestore tab from the Navigation Menu (left side of your
screen).
1. Click on the Firestore tab from the
[**Navigation Menu**](../../../../../docs/intro/ff-ui/builder.md#navigation-menu).
2. Click on the **+ Create Collection** button. If you have any other collection
already added, you can click on the Plus button.
3. Enter a collection_name (this can be anything, but we recommend 'users') and
Expand Down Expand Up @@ -127,7 +126,7 @@ this [link](https://developers.google.com/android/guides/client-auth).

:::warning[Release Guidelines]
While releasing the app, make sure
to [**get the key from Play Console**](https://docs.flutterflow.io/data-and-backend/firebase/authentication/phone-sign-in#release-mode).
to [**get the key from Play Console**](#).
:::

1. Open a terminal window:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ keywords: [FlutterFlow, Email Login, Authentication, Firebase]

Before getting started with this section:

- Complete [**Firebase Setup**](#)
- Complete [**Initial Setup**](initial-setup.md)
- Complete [**Firebase Setup**](../../../firebase/connect-to-firebase-setup.md)
- Complete [**Initial Setup**](auth-initial-setup)
:::

## Enable Email Login Provider in Firebase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Facebook login allows users to authenticate using their Facebook Accounts.

Before getting started with this section:

- Complete [**Firebase Setup**](#)
- Complete [**Initial Setup**](initial-setup.md)
- Complete [**Firebase Setup**](../../../firebase/connect-to-firebase-setup.md)
- Complete [**Initial Setup**](auth-initial-setup)
:::

## Adding Facebook sign-in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ The GitHub auth provides a convenient way for users to authenticate and log in t

Before getting started with this section:

- Complete [**Firebase Setup**](#).
- Complete [**Initial setup**](initial-setup.md) required for authentication.
- Complete [**Firebase Setup**](../../../firebase/connect-to-firebase-setup.md).
- Complete [**Initial setup**](auth-initial-setup.md) required for authentication.
:::


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Google Sign-In allows users to authenticate using their Google Accounts.

Before getting started with this section:

- Complete [**Firebase Setup**](#)
- Complete [**Initial Setup**](initial-setup.md)
- Complete [**Firebase Setup**](../../../firebase/connect-to-firebase-setup.md)
- Complete [**Initial Setup**](auth-initial-setup)
- Added **SHA-1 key** and regenerated **Config Keys**.
:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Let's build an example that uses a JWT token to log into the app. Here's how it

Before getting started with this section:

- Complete [**Firebase Setup**](#).
- Complete [**Initial setup**](initial-setup.md) required for authentication.
- Complete [**Firebase Setup**](../../../firebase/connect-to-firebase-setup.md).
- Complete [**Initial setup**](auth-initial-setup) required for authentication.
:::


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Phone login allows a user to sign in by sending an SMS message to the user's pho

Before getting started with this section:

1. Complete [**Firebase Setup**](#).
2. Complete [**Initial setup**](initial-setup.md) required for authentication.
1. Complete [**Firebase Setup**](../../../firebase/connect-to-firebase-setup.md).
2. Complete [**Initial setup**](auth-initial-setup) required for authentication.
:::


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ A collection is a group of documents. For example, you could have a 'users*'* co
:::info[Getting Started: Things to Know First]

- Get to know how to [**structure the Firebase Database**](getting-started.md#structuring-the-database).
- Ensure you've gone through and completed every step in the [**Firebase Setup**](../../firebase/connect-to-firebase-setup.md)
- Ensure you've gone through and completed every step in the
[**Firebase Setup**](../../firebase/connect-to-firebase-setup.md)
for your project.
:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ Building the chat room example comprises the following steps:

### 1. Creating a collection

[Create the collection](/data-and-backend/firebase/firestore-database-cloud-firestore/creating-collections#creating-a-collection) called *chat\_rooms*. This will be used to hold the chat room details. While defining the schema for *chat\_rooms* collection, add the fields to display its name, i.e., *chat\_room\_name.*
[**Create the collection**](creating-collections.md) called *chat\_rooms*. This will be used to hold the chat room
details.
While defining the schema for *chat\_rooms* collection, add the fields to display its name, i.e., *chat\_room\_name.*

![img_23.png](img_23.png)

Expand All @@ -63,12 +65,15 @@ Building the chat room example comprises the following steps:
To create the subcollection:

1. Click on the **Firestore** from the Navigation Menu (left side of your screen).

5. Click on the **(+)** Plus sign button.
8. A popup will appear; enter the collection name as '*messages.'*
11. **Turn on** the **Is Subcollection** toggle.
14. The dropdown list with existing collections will appear. Click on the **Unset** and select the parent collection, *chat\_rooms* in this case.
17. Click **Create** Button.
20. Next, [define the document schema](/data-and-backend/firebase/firestore-database-cloud-firestore/creating-collections#define-schema-creating-fields). While defining the schema for the 'messages' subcollection, add the fields such as *message* (to store the message body) and *from* (to store the sender name).
20. Next, [define the document schema](creating-collections.md#define-schema-creating-fields). While defining the schema for
the 'messages'
subcollection, add the fields such as *message* (to store the message body) and *from* (to store the sender name).

<div class="video-container"><iframe src="https://www.loom.
com/embed/242ba30097fd4a3986844489027185d9?sid=1c4e4ba9-dc46-4959-8b3f-5463ab004229" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
Expand All @@ -92,9 +97,13 @@ The first page shows the chat room listing, and when you tap, it opens the new p

The steps to build the chat room page are as follows:

1. Query the *chat\_rooms* collection and display the chat room names in a ListTile (inside
ListView) using the instructions [here](/data-and-backend/firebase/firestore-database-cloud-firestore/retrieving-data#querying-a-collection).
5. Add the **Navigate To** action **on Tap** of the **ListTile** and open the messages page using the instructions [here](/actions/actions/navigation/navigate#navigate-to-action). **Note**: While navigating, pass the chat room record to the next page. Learn how to pass data to the next page [here](/data-and-backend/passing-data#passing-a-record-from-a-listview-to-a-details-page).
1. Query the **chat_rooms** collection and display the chat room names in a ListTile (inside
ListView).

5. Add the **[Navigate To](../../../ff-concepts/navigation-routing/nav-overview.md#navigation-actions)** action **on
Tap** of the **ListTile** and open the messages page. **Note**: While navigating, pass the
chat room record to the next page. Learn how to
[pass data to the next page](../../../ff-concepts/navigation-routing/passing-data.md). .

<div class="video-container"><iframe src="https://www.loom.
com/embed/4ff47a7a33d64386a2e2865f87574fc2?sid=b84bf267-e569-4d3b-9b63-e20d92d2fe6f" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
Expand All @@ -113,8 +122,9 @@ The steps to build the chat room page are as follows:

![img_24.png](img_24.png)

2. On the ListView, [query](/data-and-backend/firebase/firestore-database-cloud-firestore
/retrieving-data#querying-a-collection) a subcollection as you would query any other collection; except for the subcollection, you must provide its parent collection reference (i.e., chat\_rooms reference in this case). This way, you'll only see messages from that specific chat room.
2. On the ListView, query a subcollection as you would query any
other collection; except
for the subcollection, you must provide its parent collection reference (i.e., chat\_rooms reference in this case). This way, you'll only see messages from that specific chat room.

<div class="video-container"><iframe src="https://www.loom.
com/embed/e069c07b5dd14b228099534464997bca?sid=05c512e7-60f7-4495-89e7-e0fb9f915bfa" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ FlutterFlow uses [**Firebase Cloud Messaging**](https://firebase.google.com/docs

Before getting started with this section, ensure you have:

* Completed all steps in the [**Firebase Setup**](/data-and-backend/firebase/firebase-setup).
* Completed all steps in the
[**Firebase Setup**](../../firebase/connect-to-firebase-setup.md).
* Upgraded to a [**Blaze plan**](https://firebase.google.com/pricing) for your Firebase project.
:::

Expand Down
Loading