tryHideOrShow method

bool tryHideOrShow(
  1. int separatorIndex
)

Implementation

bool tryHideOrShow(int separatorIndex) {
  if (_info.isDisabledSmartHide) {
    return false;
  }

  final isLeft = separatorIndex == 1;
  final isRight = separatorIndex == children.length - 2;
  if (!isLeft && !isRight) {
    // valid only for both ends.
    return false;
  }

  final target = children[isLeft ? 0 : children.length - 1];
  final size = target.size!;
  final coefficient = isLeft ? 1 : -1;
  if (_isNearlyZero(size)) {
    // show
    final offsetScala = maxSize! * (target.hidingPercentage ?? target.defaultPercentage!) - size;
    final offset = _info.isHorizontalSeparator ? Offset(0, offsetScala * coefficient) : Offset(offsetScala * coefficient, 0);
    resize(separatorIndex, offset);
  } else {
    // hide
    target.hidingPercentage = target.percentage!;
    final offsetScala = maxSize! * target.hidingPercentage!;
    final offset = _info.isHorizontalSeparator ? Offset(0, -offsetScala * coefficient) : Offset(-offsetScala * coefficient, 0);
    resize(separatorIndex, offset);
  }

  return true;
}