isSubMenuOpen property

bool get isSubMenuOpen

Is sub menu open

Implementation

bool get isSubMenuOpen => _isSubMenuOpen;
set isSubMenuOpen (bool isOpen)

Open or close submenu with animation. Animate double from 0 -> 1 (close -> open) and do slide calculation based on that value.

Implementation

set isSubMenuOpen(bool isOpen) {
  // Update controller value
  if (widget.controller != null &&
      widget.controller!.isSubMenuOpen != isOpen) {
    widget.controller!.isSubMenuOpen = isOpen;
  }

  if (widget.isSubMenuOpenChanged != null) {
    widget.isSubMenuOpenChanged!(isOpen);
  }

  if (widget.submenu == null ||
      (_isSubMenuOpen == isOpen && isPanning == false)) {
    return;
  }

  _subMenuAnimationController.duration =
      Duration(milliseconds: widget.duration);
  double currentAnimationProcess = getSubMenuOpenPercent();
  _isSubMenuOpen = isOpen;

  _subMenuAnimationController.reset();

  if (isOpen) {
    _subMenuAnimation = Tween<double>(begin: currentAnimationProcess, end: 1)
        .animate(CurvedAnimation(
            parent: _subMenuAnimationController, curve: Curves.easeOutCubic));

    _subMenuAnimationController.forward();
  } else {
    _subMenuAnimation = Tween<double>(begin: currentAnimationProcess, end: 0)
        .animate(CurvedAnimation(
            parent: _subMenuAnimationController, curve: Curves.easeOutCubic));

    _subMenuAnimationController.forward();
  }
}