toggle method

Future<void> toggle(
  1. int index, {
  2. Curve curve = Curves.easeInOut,
  3. Duration duration = const Duration(milliseconds: 150),
})

toggle the index item between expanding and collapsing

Implementation

Future<void> toggle(
  int index, {
  Curve curve = Curves.easeInOut,
  Duration duration = const Duration(milliseconds: 150),
}) async {
  if (_index == index) {
    await collapse(index, curve: curve, duration: duration);
  } else {
    await expand(index, curve: curve, duration: duration);
  }
}