Skip to content

Commit 2e6c293

Browse files
committed
button: Fix an inconsistency with Figma in MenuButton
1 parent b8ccd55 commit 2e6c293

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/widgets/button.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ class MenuButton extends StatelessWidget {
294294
final VoidCallback onPressed;
295295
final IconData? icon;
296296

297+
static double itemSpacing = 16;
298+
297299
static bool _debugCheckShapeAncestor(BuildContext context) {
298300
final ancestor = context.findAncestorWidgetOfExactType<MenuButtonsShape>();
299301
assert(() {
@@ -312,9 +314,18 @@ class MenuButton extends StatelessWidget {
312314

313315
final designVariables = DesignVariables.of(context);
314316

317+
// (see `trailingIcon`)
318+
assert(Theme.of(context).visualDensity == VisualDensity.standard);
319+
315320
return MenuItemButton(
316321
trailingIcon: icon != null
317-
? Icon(icon, color: designVariables.contextMenuItemText)
322+
? Padding(
323+
// This Material widget gives us 12px padding before the icon --
324+
// or more or less, depending on Theme.of(context).visualDensity,
325+
// hence the `assert` above.
326+
padding: EdgeInsetsDirectional.only(start: itemSpacing - 12),
327+
328+
child: Icon(icon, color: designVariables.contextMenuItemText))
318329
: null,
319330
style: MenuItemButton.styleFrom(
320331
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),

0 commit comments

Comments
 (0)