How to have toggle without needing to create multiple variables?

Hi, I have a collection list that i’ve binded and I only want to show certain things on toggle.

Normally, i would create a boolean variable and bind it to the toggle to display / hide the subtasks.

But now the number of main tasks is dynamic. How do I execute this toggle without needing to create a ton of boolean variables?

use a single variable of type object. assuming you have unique ids for each item in the list, when you toggle partially change the variable with the current id as path to true/false. to check the state of a toggle just check the value of yourvariable[id]