Commit 620fb875 authored by Hans Muller's avatar Hans Muller

Enable lining up the last tool bar action trailing list item elements (#3597)

parent 4aa37568
...@@ -195,7 +195,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -195,7 +195,7 @@ class ListDemoState extends State<ListDemo> {
child: new Scrollbar( child: new Scrollbar(
child: new MaterialList( child: new MaterialList(
type: _itemType, type: _itemType,
padding: new EdgeInsets.all(_dense ? 4.0 : 8.0), padding: new EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0),
children: listItems children: listItems
) )
) )
......
...@@ -84,7 +84,7 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -84,7 +84,7 @@ class MenuDemoState extends State<MenuDemo> {
] ]
), ),
body: new Block( body: new Block(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.symmetric(vertical: 8.0),
children: <Widget>[ children: <Widget>[
// Pressing the PopupMenuButton on the right of this item shows // Pressing the PopupMenuButton on the right of this item shows
// a simple menu with one disabled item. Typically the contents // a simple menu with one disabled item. Typically the contents
...@@ -92,6 +92,7 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -92,6 +92,7 @@ class MenuDemoState extends State<MenuDemo> {
new ListItem( new ListItem(
title: new Text('An item with a context menu button'), title: new Text('An item with a context menu button'),
trailing: new PopupMenuButton<String>( trailing: new PopupMenuButton<String>(
padding: EdgeInsets.zero,
onSelected: showMenuSelection, onSelected: showMenuSelection,
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[ itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
new PopupMenuItem<String>( new PopupMenuItem<String>(
...@@ -115,6 +116,7 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -115,6 +116,7 @@ class MenuDemoState extends State<MenuDemo> {
new ListItem( new ListItem(
title: new Text('An item with a sectioned menu'), title: new Text('An item with a sectioned menu'),
trailing: new PopupMenuButton<String>( trailing: new PopupMenuButton<String>(
padding: EdgeInsets.zero,
onSelected: showMenuSelection, onSelected: showMenuSelection,
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
new PopupMenuItem<String>( new PopupMenuItem<String>(
...@@ -153,6 +155,7 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -153,6 +155,7 @@ class MenuDemoState extends State<MenuDemo> {
// a menu whose current value is highlighted and aligned over the // a menu whose current value is highlighted and aligned over the
// list item's center line. // list item's center line.
new PopupMenuButton<String>( new PopupMenuButton<String>(
padding: EdgeInsets.zero,
initialValue: _simpleValue, initialValue: _simpleValue,
onSelected: showMenuSelection, onSelected: showMenuSelection,
child: new ListItem( child: new ListItem(
...@@ -179,6 +182,7 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -179,6 +182,7 @@ class MenuDemoState extends State<MenuDemo> {
new ListItem( new ListItem(
title: new Text('An item with a checklist menu'), title: new Text('An item with a checklist menu'),
trailing: new PopupMenuButton<String>( trailing: new PopupMenuButton<String>(
padding: EdgeInsets.zero,
onSelected: showCheckedMenuSelections, onSelected: showCheckedMenuSelections,
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[ itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
new CheckedPopupMenuItem<String>( new CheckedPopupMenuItem<String>(
......
...@@ -398,6 +398,7 @@ class PopupMenuButton<T> extends StatefulWidget { ...@@ -398,6 +398,7 @@ class PopupMenuButton<T> extends StatefulWidget {
this.onSelected, this.onSelected,
this.tooltip: 'Show menu', this.tooltip: 'Show menu',
this.elevation: 8, this.elevation: 8,
this.padding: const EdgeInsets.all(8.0),
this.child this.child
}) : super(key: key) { }) : super(key: key) {
assert(itemBuilder != null); assert(itemBuilder != null);
...@@ -421,6 +422,11 @@ class PopupMenuButton<T> extends StatefulWidget { ...@@ -421,6 +422,11 @@ class PopupMenuButton<T> extends StatefulWidget {
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24 /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
final int elevation; 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. /// The widget below this widget in the tree.
final Widget child; final Widget child;
...@@ -453,6 +459,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> { ...@@ -453,6 +459,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
if (config.child == null) { if (config.child == null) {
return new IconButton( return new IconButton(
icon: Icons.more_vert, icon: Icons.more_vert,
padding: config.padding,
tooltip: config.tooltip, tooltip: config.tooltip,
onPressed: () { showButtonMenu(context); } onPressed: () { showButtonMenu(context); }
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment