onClick method

void onClick(
  1. String key
)

Implementation

void onClick(String key) {
  List<String> activeList = activeIndex;
  if (activeList.indexOf(key) >= 0) {
    activeList.remove(key);
  } else {
    // 手风琴模式判断
    if (widget.accordion) {
      activeList = [key];
    } else {
      activeList.add(key);
    }
  }

  setState(() {
    activeIndex = activeList;
  });

  if (widget.onChange is Function) widget.onChange!(activeList);
}