fix: dispatch menu onPressed manually (#29353)

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2026-06-27 18:40:47 +05:30 committed by GitHub
parent 6e1143e799
commit e9d1951858
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,14 +49,21 @@ class BaseActionButton extends ConsumerWidget {
if (menuItem) {
final iconColor = this.iconColor;
final onPressed = this.onPressed;
return MenuItemButton(
closeOnActivate: false,
style: MenuItemButton.styleFrom(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
),
leadingIcon: Icon(iconData, color: iconColor, size: 20),
onPressed: onPressed,
onPressed: onPressed == null
? null
: () {
onPressed();
MenuController.maybeOf(context)?.close();
},
child: Text(label, style: TextStyle(fontSize: 15, color: iconColor)),
);
}