Enums
In FlutterFlow, Enums (enumerations) provide a method for defining a set of named constants. They are typically used to represent a group of related values in a more readable and safe manner.
They prevent invalid values from being assigned. For example, if you have an enum for days of the week, you can't mistakenly assign a non-existent day. In contrast, with strings or numbers, you might accidentally use an invalid or misspelled value like "Sundey" or "Sinday".
Here are some real-world examples where using Enums is beneficial:
- Application States: A media player might use enums to keep track of playback states (e.g., playing, paused, stopped).
- Product Types, Sizes, or Categories: A clothing store app might use enums to categorize clothing sizes (small, medium, large).
- Order or Process Status: For tracking the status of orders, processes, or tasks (pending, inProgress, completed, canceled).
Create and use Enums
- You can create Enums from the left side navigation menu and add values to it.
- Access the Enum values by navigating to the Set from Variable menu, then selecting Enums > [your enum name] > Values.