FlutterFlow Docs
Search…
⌃K

Conditional Logic

Conditional logic allows you to add your own logic to the app. This is helpful when you want to display something or set a value from a variable based on a certain condition(s). For example, displaying subscribe button only if the user is logged in and not already subscribed. Another example is showing discount coupon values based on previously purchased items.
You can add conditional logic using a single condition or multiple conditions (AND or OR) and use the conditional value using the If/then/else flow.
Conditional logic

Single condition

Using this, you can define a single condition based on two values. You can set these two values either manually or from a variable. This can return True or False (based on the condition).
While adding a condition, you can specify how to compare two values using any of the following options:
  • Equal To
  • Not Equal To
  • Less Than
  • Greater Than
  • Less Than Or Equal To
  • Great Than Or Equal To
  • Is Set
  • Is Not Set
To add a single condition:
  • From the Set from Variable menu, select Conditions > Single Condition.
  • Click on the First Value and select the Source (e.g., local state variable).
  • Specify how you would like to compare the first value with the second one (e.g., Equal To, Less Than).
  • Click on the Second Value and provide the value by selecting a Specific Value or From Variable.
Adding single condition

Multiple conditions (AND/OR)

Using this, you can add multiple single conditions using AND/OR. For example, on the EventDetails page, you might want to display the edit button only if the current user created the event AND when the edit mode is off.
Multiple condition example
To add multiple conditions:
  • From the Set from Variable menu, select Conditions > Combine Conditions.
  • Under the First Condition, click on UNSET and add the single condition or directly provide the variable that returns a boolean value (True/False).
  • If you want all the conditions to be true, keep the AND tab selected. And if you want any one condition to be true, change it to OR.
  • Similarly, add the next condition.
  • To add more conditions, click on the + Add button.
Adding multiple conditions
You can also mix multiple AND conditions with the OR conditions. Here is an example of displaying the delete button when a user is either admin OR event manager AND is logged in.
Mixing AND with OR conditions

Conditional value (If/then/else)

Conditional Value allows you to provide the dynamic variable based on different conditions (either single or multiple). For every condition, you can provide a variable that will be set if the condition is true. You can also specify a default variable in case all the condition fails.
For example, display different temperature colors based on different values (i.e., show blue color when the temperature is less than 0, show orange color when the temperature is less than 28; otherwise, show red color).
Conditional value example
To add conditional value:
  • From the Set from Variable menu, select Conditional Value.
  • Under the First Condition, provide the IF condition by clicking on UNSET.
  • Now, besides the THEN, click Set from Variable and provide the source that will be set if the first condition is true.
  • If the first condition fails, provide another one by clicking on the + button.
  • If all the above conditions fail, provide the variable inside the last Else section.
  • In case the returning type is different, set it from the Return Type section.
  • If the final result is null or empty, you can specify the Default Variable Value.
Conditional value
Adding conditional value