collapse method

Future<bool> collapse(
  1. int index
)

Collapses the item at the given index, returning true if collapsed.

This method should typically not be called while the widget tree is being rebuilt.

Implementation

Future<bool> collapse(int index) async {
  if (_expanded.length <= _min || !_expanded.contains(index)) {
    return false;
  }

  _expanded.remove(index);
  await controllers[index]!.reverse();

  notifyListeners();

  return true;
}