From 620fb87567c42f0d14c36877839f31437afe6e53 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Wed, 27 Apr 2016 17:34:59 -0700 Subject: [PATCH] Enable lining up the last tool bar action trailing list item elements (#3597) --- examples/material_gallery/lib/demo/list_demo.dart | 2 +- examples/material_gallery/lib/demo/menu_demo.dart | 6 +++++- packages/flutter/lib/src/material/popup_menu.dart | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/material_gallery/lib/demo/list_demo.dart b/examples/material_gallery/lib/demo/list_demo.dart index 566bf7a45a..d6714c3a04 100644 --- a/examples/material_gallery/lib/demo/list_demo.dart +++ b/examples/material_gallery/lib/demo/list_demo.dart @@ -195,7 +195,7 @@ class ListDemoState extends State { child: new Scrollbar( child: new MaterialList( type: _itemType, - padding: new EdgeInsets.all(_dense ? 4.0 : 8.0), + padding: new EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0), children: listItems ) ) diff --git a/examples/material_gallery/lib/demo/menu_demo.dart b/examples/material_gallery/lib/demo/menu_demo.dart index d872da59fc..a5df0e16fd 100644 --- a/examples/material_gallery/lib/demo/menu_demo.dart +++ b/examples/material_gallery/lib/demo/menu_demo.dart @@ -84,7 +84,7 @@ class MenuDemoState extends State { ] ), body: new Block( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.symmetric(vertical: 8.0), children: [ // Pressing the PopupMenuButton on the right of this item shows // a simple menu with one disabled item. Typically the contents @@ -92,6 +92,7 @@ class MenuDemoState extends State { new ListItem( title: new Text('An item with a context menu button'), trailing: new PopupMenuButton( + padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ new PopupMenuItem( @@ -115,6 +116,7 @@ class MenuDemoState extends State { new ListItem( title: new Text('An item with a sectioned menu'), trailing: new PopupMenuButton( + padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ new PopupMenuItem( @@ -153,6 +155,7 @@ class MenuDemoState extends State { // a menu whose current value is highlighted and aligned over the // list item's center line. new PopupMenuButton( + padding: EdgeInsets.zero, initialValue: _simpleValue, onSelected: showMenuSelection, child: new ListItem( @@ -179,6 +182,7 @@ class MenuDemoState extends State { new ListItem( title: new Text('An item with a checklist menu'), trailing: new PopupMenuButton( + padding: EdgeInsets.zero, onSelected: showCheckedMenuSelections, itemBuilder: (BuildContext context) => >[ new CheckedPopupMenuItem( diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 1db9b645ca..dee0d12515 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -398,6 +398,7 @@ class PopupMenuButton extends StatefulWidget { this.onSelected, this.tooltip: 'Show menu', this.elevation: 8, + this.padding: const EdgeInsets.all(8.0), this.child }) : super(key: key) { assert(itemBuilder != null); @@ -421,6 +422,11 @@ class PopupMenuButton extends StatefulWidget { /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 final int elevation; + /// Matches IconButton's 8 dps padding by default. In some cases, notably where + /// this button appears as the trailing element of a list item, it's useful to be able + /// to set the padding to zero. + final EdgeInsets padding; + /// The widget below this widget in the tree. final Widget child; @@ -453,6 +459,7 @@ class _PopupMenuButtonState extends State> { if (config.child == null) { return new IconButton( icon: Icons.more_vert, + padding: config.padding, tooltip: config.tooltip, onPressed: () { showButtonMenu(context); } );