toggle method
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);
}
}