示例#1
0
        void _handleTap()
        {
            if (this.widget.isAnimation)
            {
                this._rotationController.forward();
            }
            else
            {
                if (!this._isDropdown)
                {
                    this.setState(() => this._isDropdown = true);
                }
            }
            var renderBox = (RenderBox)this._dropdownKey.currentContext.findRenderObject();
            var position  = renderBox.localToGlobal(new Offset(0, dy: renderBox.size.height));

            this._dropdownRoute = new _CustomDropdownRoute <T>(
                items: this.widget.items,
                position: position,
                this._selectedIndex ?? 0,
                elevation: this.widget.elevation,
                isAnimation: this.widget.isAnimation,
                headerWidget: this.widget.headerWidget,
                footerWidget: this.widget.footerWidget,
                style: this.widget.style
                );

            Navigator.push(context: this.context, route: this._dropdownRoute).Then(newValue => {
                if (this.widget.isAnimation)
                {
                    this._rotationController.reverse();
                }
                else
                {
                    if (this._isDropdown)
                    {
                        this.setState(() => this._isDropdown = false);
                    }
                }
                this._dropdownRoute = null;
                if (!this.mounted || newValue == null)
                {
                    return;
                }

                this.widget.onChanged?.Invoke((T)newValue);
            });
        }
示例#2
0
 void _removeDropdownRoute()
 {
     this._dropdownRoute?.dismiss();
     this._dropdownRoute = null;
 }