toggleExpansion method

void toggleExpansion(
  1. int index
)

Implementation

void toggleExpansion(int index) {
  if (expandedItems.contains(index)) {
    expandedItems.remove(index);
    print("Collapsed: $index");
  } else {
    expandedItems.add(index);
    print("Expanded: $index");
  }
  print("Expanded Items: $expandedItems");
}