Skip to content

Commit 953ca54

Browse files
committed
Added countcontroller widget
1 parent 51b3d27 commit 953ca54

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
slug: countcontroller
3+
title: CountController
4+
tags: []
5+
description: Learn how to add CountController in your FlutterFlow app.
6+
sidebar_position: 8
7+
---
8+
9+
# CountController
10+
11+
The CountController widget is used to increment and decrement the count or number.
12+
13+
You could use the CountController widget to set the quantity of any product when buying in an e-commerce app.
14+
15+
## Adding CountController to your project
16+
17+
Here's an example of how you can use a CountController widget in your project:
18+
19+
1. First, drag the **CountController** widget from the **Form Elements** tab (in the Widget Panel) or add it directly from the widget tree.
20+
2. Move to the properties panel (in the right) and scroll down to the **Count Controller Properties**.
21+
3. The number on CountController appears as soon as it is loaded, called the Initial Count, 0 by default. To change this initial count, enter the value in the **Initial Count** input box. You can also set this value dynamically by having it **Set from Variable**. This can be used to display the default quantity of a product in an E-commerce app.
22+
4. The Step Size property sets the value by which the count should be increased or decreased. The default value is 1. To change this, enter the value in the **Step Size** input box.
23+
5. To allow users to set the valid count or quantity, you can limit the CountController range (min and max count) by specifying the value in the **Minimum** and **Maximum** input boxes.
24+
25+
![Adding CountController widget](imgs/adding-count-controller-widget.gif)
26+
27+
## Trigger action on count change
28+
29+
Let's see how to trigger an action when the count changes on this widget. This is helpful when you want to update the latest count in your backend (make API call, create/update Firestore document) as the count changes.
30+
31+
![Showing the latest count as it changes](imgs/show-latest-count.gif)
32+
33+
To do so:
34+
35+
1. Select **CountController**, select **Actions** from the Properties panel (the right menu), and click **+ Add Action**.
36+
2. You will notice that the **Type of Action** (aka callback) is already set to **On Count Changed**. That means actions added under this will be called whenever the count changes.
37+
3. Now you can add any action here.
38+
39+
Here is an example of updating the count in an [app state variable](../../../../resources/data-representation/app-state).
40+
41+
![Trigger action on count change](imgs/adding-on-count-change.gif)
42+
43+
## Customizing CountController
44+
45+
The Properties Panel can be used to customize the appearance and behavior of your widget.
46+
47+
### Customizing icon
48+
49+
To customize the decrement icon:
50+
51+
1. Select the **CountController** widget from the widget tree or the canvas area.
52+
2. Move to the properties panel, and find the **Style Properties** section.
53+
3. To change the icon, click on the already selected icon and then search and select the new icon.
54+
4. To change the icon size, enter the value in the **Icon Size** property.
55+
5. To change the icon color, find the **Icon Color** property, click on the box next to the selected color, select the color, and click **Use Color** or click on **Unset** and enter a Hex Code directly.
56+
57+
![customize-icon](imgs/customize-icon.gif)
1.39 MB
Loading
5.89 MB
Loading
2.64 MB
Loading
541 KB
Loading

0 commit comments

Comments
 (0)