예제 #1
0
        void _handleTap()
        {
            RenderBox  itemBox    = (RenderBox)this.context.findRenderObject();
            Rect       itemRect   = itemBox.localToGlobal(Offset.zero) & itemBox.size;
            EdgeInsets menuMargin = ButtonTheme.of(this.context).alignedDropdown
                ? DropdownConstants._kAlignedMenuMargin
                : DropdownConstants._kUnalignedMenuMargin;

            D.assert(this._dropdownRoute == null);
            this._dropdownRoute = new _DropdownRoute <T>(
                items: this.widget.items,
                buttonRect: menuMargin.inflateRect(itemRect),
                padding: DropdownConstants._kMenuItemPadding,
                selectedIndex: this._selectedIndex ?? 0,
                elevation: this.widget.elevation,
                theme: Theme.of(this.context, shadowThemeOnly: true),
                style: this._textStyle,
                barrierLabel: MaterialLocalizations.of(this.context).modalBarrierDismissLabel
                );

            Navigator.push(this.context, this._dropdownRoute).Then(newValue => {
                _DropdownRouteResult <T> value = newValue as _DropdownRouteResult <T>;
                this._dropdownRoute            = null;
                if (!this.mounted || newValue == null)
                {
                    return;
                }

                if (this.widget.onChanged != null)
                {
                    this.widget.onChanged(value.result);
                }
            });
        }