Any help would be greatly appreciated. I'm having trouble with the logic of setting this up.
The Goal:
When the user navigates to this items page, a new document on a "project" sub collection is created. There is an action button on the items page that updates the document with the chosen items and the quantities from the dynamic list to an array.
I have a component to generate the dynamic list. the component has a toggle icon, text (for item name) and a count controller (for quantity).
The toggle icon adds the items to the app state and count controller changes the quantity.
After a few days stuck on this I was able to get almost everything to work, but I'm new to flutterflow and I feel like I'm missing something on the logic of the binding or component setup.
The issue:
Once I toggle the item, I can't get the count controller to update the app state related to the quantity.
If I set the quantity on the count controller first and then toggle the item, the app state shows the information as intended and saves the array correctly, but if I change the counter controller value after the toggle, it resets the toggle and once I toggle it to (true) again it duplicates the item in the app state (even with a conditional to remove items from list if toggle is set to false)
Another reason the goal was to toggle the item first is that I have a conditional for the count controller to appear only if the item is toggled. (I'm trying to avoid clutter on the page by showing the count controller only if users chooses the item)
Component setup:
Component parameters - Parameter 1 (Boolean), Parameter 2 (string) and Parameter 3 (Integer).
Component States - showcontainer (boolean), componentnumbers (integer)
Component Binding / Actions:
Toggle Value - App State (List A) -> List Contain Items -> Create Data Type Object (List A) -> Set Fields: Model (Parameter 2) QTY (Count Controller) / No further changes.
Action - Update Component State -> Showcontainer (boolean), Update type - toggle value, no rebuild
Text == Parameter 2
Counter Controller - Action -> Update Component State / componentnumbers (integer) / update type - Increment decrement (Count Controller) / No rebuild
Action 2 - Update App State (List A) / Update type - update item at index (parameter 3) / update type (update fields) - Items_A (QTY, Increment decrement (count controller)) / no rebuild
Page Setup:
Querying Collection from Item collection to generate Dynamic list with the component
Component settings:
Unique Key - Item ID
Parameter 1 - App State List A (List Contain Item) / Create Data type Object / Set Fields - Model (Item Doc property Model) / QTY (Item Doc property QTY) / No further changes
Parameter 2 - Item Doc Property Model
Parameter 3 - Item Doc Property QTY
Action Button - Action 1 / Backend Call (Update Document) / Reference (Project Sub Colletction) / Set Fields (Choosen_item List<Data(ItemsA)>) / Type List<Data(ItemsA)> / Field (Choosen Item) / Set value / App State (List_A) / No further change
Action 2 - Navigate to the next page along with passing some parameters
Collection / States Setup:
App State: List_A: List<Data(ItemsA)>
Data Schema: ItemsA - QTY (Integer), Model (string) Checked (boolean)
Items Collection (has the usual) - Model (String), QTY (Integer), Checked (Boolean), Item ID (String)
Project (Collection) / Items List Sub collection - Choosen_item (List<Data(ItemsA)> ), ProjectID (String) and ListID (string)