isMenuOpen property
set
isMenuOpen
(bool isOpen)
Open or close menu with animation. Animate double from 0 -> 1 (close -> open) and do slide and width calculations based on that value.
Implementation
set isMenuOpen(bool isOpen) {
// Update controller value
if (widget.controller != null && widget.controller!.isMenuOpen != isOpen) {
widget.controller!.isMenuOpen = isOpen;
}
if (widget.isMenuOpenChanged != null) {
widget.isMenuOpenChanged!(isOpen);
}
if (widget.menu == null || (_isMenuOpen == isOpen && isPanning == false)) {
return;
}
_menuAnimationController.duration = Duration(milliseconds: widget.duration);
double currentAnimationProcess = getMenuOpenPercent();
_isMenuOpen = isOpen;
_menuAnimationController.reset();
if (isOpen) {
_menuAnimation = Tween<double>(begin: currentAnimationProcess, end: 1)
.animate(CurvedAnimation(
parent: _menuAnimationController,
curve: Curves.easeOutCubic,
));
_menuAnimationController.forward();
} else {
_menuAnimation = Tween<double>(begin: currentAnimationProcess, end: 0)
.animate(CurvedAnimation(
parent: _menuAnimationController,
curve: Curves.easeOutCubic,
));
_menuAnimationController.forward();
}
}