|
| 1 | +--- |
| 2 | +slug: slider |
| 3 | +title: Slider |
| 4 | +tags: [] |
| 5 | +description: Learn how to add Slider in your FlutterFlow app. |
| 6 | +sidebar_position: 4 |
| 7 | +--- |
| 8 | + |
| 9 | +# Slider |
| 10 | + |
| 11 | +The Slider widget is used to select a single value from a range of values. You define the min and max value for the slider, and users can choose the value between the specified range by dragging the slider thumb (sliding circle). |
| 12 | + |
| 13 | +For example, you can use the Slider widget to allow users to set the volume, set the donation amount, etc. |
| 14 | + |
| 15 | +## Adding Slider |
| 16 | + |
| 17 | +Let's build an example of using the Slider widget and retrieve its value in a Text widget. |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +The steps to build the example are as follows: |
| 22 | + |
| 23 | +1. First, add the **Slider** widget from the **Form Elements** tab or add it directly from the widget tree. |
| 24 | +2. Now, add the **Text** widget to display the slider value. |
| 25 | +3. Keep the **Text** widget selected, Move to the properties panel, and click on the **Set from Variable**. This will open a new panel. |
| 26 | + 1. Set **Source** to **Widget State**. |
| 27 | + 2. Set the **Available Options** to **Slider**. If you add multiple sliders, the names would be like Slider1, Slider2, and so on. |
| 28 | + 3. Set the **Number Format Option** if you wish to. |
| 29 | + 4. Click **Confirm**. |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +## Setting initial value |
| 34 | + |
| 35 | +Sometimes you might want to display the slider with the default value. For example, showing the volume slider with the audible volume value. You can do so by setting the initial value for the Slider. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +## Customization |
| 40 | + |
| 41 | +You can customize the appearance and behavior of the widget using the various properties available under the properties panel. |
| 42 | + |
| 43 | +### Setting platform type |
| 44 | + |
| 45 | +You can set the platform type to *Adaptive or Android* for **this widget. Selecting the Adaptive type will display the widget in its native style. That means the widget will show iOS-style rendering when running on iOS devices and Android-style rendering when running on Android devices. |
| 46 | + |
| 47 | +To set the platform type: |
| 48 | + |
| 49 | +1. Select the **Slider** widget from the widget tree or the canvas area. |
| 50 | +2. Move to the properties panel and open the **Platform** section. |
| 51 | +3. Set the **Platform Type** among the **Android** or **Adaptive**. |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +### Defining slider range |
| 56 | + |
| 57 | +You can define the slider range by setting the min and max values. |
| 58 | + |
| 59 | +To set the min and max values: |
| 60 | + |
| 61 | +1. Select the **Slider** widget from the widget tree or the canvas area. |
| 62 | +2. Move to the properties panel and scroll down to the **Slider Properties** section. |
| 63 | +3. Find the **Min** property and enter the value. This will be the start value of the range. |
| 64 | +4. Find the **Max** property and enter the value. This will be the end value of the range. |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +### Setting step size |
| 69 | + |
| 70 | +By default, you can move and stop the slider thumb at any place on the slider track. To make the slider thumb stop at a specific interval, you can set the step size value. |
| 71 | + |
| 72 | +:::info |
| 73 | +If the range is not evenly divisible by the step size, the slider thumb will stop at the closest value in the range. |
| 74 | +::: |
| 75 | + |
| 76 | +To set the step size: |
| 77 | + |
| 78 | +1. Select the **Slider** widget from the widget tree or the canvas area. |
| 79 | +2. Move to the properties panel and scroll down to the **Slider Properties** section. |
| 80 | +3. Find the **Step Size** property and enter the value. |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | +### Changing color |
| 85 | + |
| 86 | +To change the slider colors: |
| 87 | + |
| 88 | +1. Select the **Slider** widget from the widget tree or the canvas area. |
| 89 | +2. Move to the properties panel and scroll down to the **Slider Properties** section. |
| 90 | +3. To change the active color, find the **Active Color** property, click on the box next to the already selected color, select the color, and then click **Use Color** or click on an already selected color ****and enter a Hex Code directly. You can also choose the color by clicking the **Palette** and **Simple** button. |
| 91 | +4. To change the inactive color, find the **Inactive Color** property, click on the box next to the already selected color, select the color, and then click **Use Color** or click on an already selected color ****and enter a Hex Code directly. You can also choose the color by clicking the **Palette** and **Simple** button. |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +### Showing slider value |
| 96 | + |
| 97 | +You can show the slider value while moving the slider thumb on the track. The value appears as a tooltip above the slider thumb. |
| 98 | + |
| 99 | +To show the slider value: |
| 100 | + |
| 101 | +1. Select the **Slider** widget from the widget tree or the canvas area. |
| 102 | +2. Move to the properties panel and scroll down to the **Slider Properties** section. |
| 103 | +3. Find the **Show Value** property and turn on the toggle. |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +## Trigger action on change |
| 108 | + |
| 109 | +See how to [trigger an action when a selection changes](../../../../../resources/ui-building-blocks/widgets/widget-commonalities#trigger-action-on-selection-change) on this widget. |
0 commit comments