How to dynamically sum review ratings in FlutterFlow without manually adding an action for each new review?

Actions & Logic

Hello FlutterFlow community,

I'm building an app where users (clients) can leave reviews for service providers. Each review includes a rating (from 1 to 5). I need to calculate the total rating and the average rating for each provider dynamically, every time a new review is added. However, I'm facing a challenge.

Here’s the issue:

  • I need to sum the ratings of all reviews for a provider and calculate the average.

  • I can query the reviews using the Firestore query and get a list of reviews for a specific provider (using the reviewed_user_ref).

  • The challenge is: how can I dynamically sum the ratings and calculate the average for all reviews in the list without manually adding an action for every new review that a client leaves?

I want to avoid manually adding an action for each review and instead find a way to automatically update the total and average ratings when a new review is submitted.

Is there a way to achieve this in FlutterFlow? Can we iterate through the list of reviews dynamically or use a different approach to update the total and average ratings?

Any help or guidance would be greatly appreciated!

Thank you!

What have you tried so far?
  • have tried using Inline Functions in FlutterFlow to sum the review ratings, but FlutterFlow doesn’t allow iterating over the list of reviews directly with methods like map or reduce.

  • I attempted using Filter List Items, but it requires a boolean condition, which didn’t fit my use case.

  • I also tried Item at Index and Get Document Property, but I couldn’t dynamically access all the reviews or perform the sum without manually adding an action for each review.

  • I explored using Set Variable to accumulate the sum, but I am facing issues because the number of reviews for each provider is dynamic, and I don’t want to manually add actions for each new review.

Did you check FlutterFlow's Documentation for this topic?
No
3 replies