openPopup method
void
openPopup()
Implementation
void openPopup() {
assert(isEnabled, 'The ComboBox must be enabled to open a popup');
final textDirection = Directionality.maybeOf(context);
const EdgeInsetsGeometry menuMargin = _kAlignedMenuMargin;
final navigator = Navigator.of(context);
assert(_comboboxRoute == null);
final itemBox = context.findRenderObject()! as RenderBox;
final itemRect = itemBox.localToGlobal(Offset.zero,
ancestor: navigator.context.findRenderObject()) &
itemBox.size;
_comboboxRoute = _ComboBoxRoute<T>(
acrylicEnabled: DisableAcrylic.of(context) == null,
items: widget.items!,
buttonRect: menuMargin.resolve(textDirection).inflateRect(itemRect),
padding: _kMenuItemPadding.resolve(textDirection),
selectedIndex: _selectedIndex,
elevation: widget.elevation,
capturedThemes:
InheritedTheme.capture(from: context, to: navigator.context),
style: textStyle!,
barrierLabel: FluentLocalizations.of(context).modalBarrierDismissLabel,
popupColor: widget.popupColor,
);
navigator
.push(_comboboxRoute!)
.then<void>((_ComboBoxRouteResult<T>? newValue) {
closePopup();
if (!mounted || newValue == null) return;
onChanged(newValue.result);
});
if (widget.onTap != null) {
widget.onTap!();
}
}