Skip to content

Custom Actions in FlutterFlow Studio differ from custom functions in that they always return a Future. This makes them particularly useful for complex operations that may take time to complete, such as querying a database or calling a function that returns results after a delay. Additionally, Custom Actions are beneficial when you want to add a third-party dependency from pub.dev, allowing you to extend the capabilities of your application with external packages.

Key Use Cases

  • Database Queries: Perform complex queries to retrieve or update data in a database.
  • API Calls: Make asynchronous HTTP requests to external APIs and handle the responses.
  • File Operations: Manage file reading or writing operations that require time to complete.
  • Third-Party Integrations: Incorporate external packages and dependencies to enhance functionality, such as an external analytics package.

Using a Custom Action

Once your Action code is finalized, saved, and compiled, you can start using this action as a part of your Action flow.

In the following example, we have a Custom Action called executeSearch that takes an argument searchItem that is the search string from the search TextField of an ecommerce app’s HomePage.

Using the Custom Action Result

In our previous example, we enabled the Return Value of the Custom Action to return a List<Product> when the search keyword is valid. With this change the code will change from

Future executeSearch(String searchItem) async {
// Add your function code here!
}

to

Future<List<ProductStruct>> executeSearch(String searchItem) async {
// Add your function code here!
}

Let’s modify our Action Flow now so we can use the custom action result values within our Action Flow.

Last updated on