Remove two clients of MaterialList (#8076)

Clients should use ListView instead.
This commit is contained in:
Adam Barth 2017-02-11 23:33:56 -08:00 committed by GitHub
parent 7cde72fea2
commit 547f89d0c0
2 changed files with 41 additions and 41 deletions

View file

@ -24,7 +24,7 @@ class ListDemoState extends State<ListDemo> {
bool _showDividers = false; bool _showDividers = false;
bool _reverseSort = false; bool _reverseSort = false;
List<String> items = <String>[ List<String> items = <String>[
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N' 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
]; ];
void changeItemType(MaterialListType type) { void changeItemType(MaterialListType type) {
@ -38,7 +38,7 @@ class ListDemoState extends State<ListDemo> {
_bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) { _bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) {
return new Container( return new Container(
decoration: new BoxDecoration( decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: Colors.black26)) border: new Border(top: new BorderSide(color: Colors.black26)),
), ),
child: new ListView( child: new ListView(
shrinkWrap: true, shrinkWrap: true,
@ -49,7 +49,7 @@ class ListDemoState extends State<ListDemo> {
trailing: new Radio<MaterialListType>( trailing: new Radio<MaterialListType>(
value: _showAvatars ? MaterialListType.oneLineWithAvatar : MaterialListType.oneLine, value: _showAvatars ? MaterialListType.oneLineWithAvatar : MaterialListType.oneLine,
groupValue: _itemType, groupValue: _itemType,
onChanged: changeItemType onChanged: changeItemType,
) )
), ),
new ListItem( new ListItem(
@ -58,7 +58,7 @@ class ListDemoState extends State<ListDemo> {
trailing: new Radio<MaterialListType>( trailing: new Radio<MaterialListType>(
value: MaterialListType.twoLine, value: MaterialListType.twoLine,
groupValue: _itemType, groupValue: _itemType,
onChanged: changeItemType onChanged: changeItemType,
) )
), ),
new ListItem( new ListItem(
@ -67,8 +67,8 @@ class ListDemoState extends State<ListDemo> {
trailing: new Radio<MaterialListType>( trailing: new Radio<MaterialListType>(
value: MaterialListType.threeLine, value: MaterialListType.threeLine,
groupValue: _itemType, groupValue: _itemType,
onChanged: changeItemType onChanged: changeItemType,
) ),
), ),
new ListItem( new ListItem(
dense: true, dense: true,
@ -80,8 +80,8 @@ class ListDemoState extends State<ListDemo> {
_showAvatars = value; _showAvatars = value;
}); });
_bottomSheet?.setState(() { }); _bottomSheet?.setState(() { });
} },
) ),
), ),
new ListItem( new ListItem(
dense: true, dense: true,
@ -93,8 +93,8 @@ class ListDemoState extends State<ListDemo> {
_showIcons = value; _showIcons = value;
}); });
_bottomSheet?.setState(() { }); _bottomSheet?.setState(() { });
} },
) ),
), ),
new ListItem( new ListItem(
dense: true, dense: true,
@ -106,8 +106,8 @@ class ListDemoState extends State<ListDemo> {
_showDividers = value; _showDividers = value;
}); });
_bottomSheet?.setState(() { }); _bottomSheet?.setState(() { });
} },
) ),
), ),
new ListItem( new ListItem(
dense: true, dense: true,
@ -119,11 +119,11 @@ class ListDemoState extends State<ListDemo> {
_dense = value; _dense = value;
}); });
_bottomSheet?.setState(() { }); _bottomSheet?.setState(() { });
} },
) ),
) ),
] ],
) ),
); );
}); });
} }
@ -131,12 +131,10 @@ class ListDemoState extends State<ListDemo> {
Widget buildListItem(BuildContext context, String item) { Widget buildListItem(BuildContext context, String item) {
Widget secondary; Widget secondary;
if (_itemType == MaterialListType.twoLine) { if (_itemType == MaterialListType.twoLine) {
secondary = new Text( secondary = new Text("Additional item information.");
"Additional item information."
);
} else if (_itemType == MaterialListType.threeLine) { } else if (_itemType == MaterialListType.threeLine) {
secondary = new Text( secondary = new Text(
"Even more additional list item information appears on line three." "Even more additional list item information appears on line three.",
); );
} }
return new ListItem( return new ListItem(
@ -145,7 +143,7 @@ class ListDemoState extends State<ListDemo> {
leading: _showAvatars ? new CircleAvatar(child: new Text(item)) : null, leading: _showAvatars ? new CircleAvatar(child: new Text(item)) : null,
title: new Text('This item represents $item.'), title: new Text('This item represents $item.'),
subtitle: secondary, subtitle: secondary,
trailing: _showIcons ? new Icon(Icons.info, color: Theme.of(context).disabledColor) : null trailing: _showIcons ? new Icon(Icons.info, color: Theme.of(context).disabledColor) : null,
); );
} }
@ -183,22 +181,21 @@ class ListDemoState extends State<ListDemo> {
_reverseSort = !_reverseSort; _reverseSort = !_reverseSort;
items.sort((String a, String b) => _reverseSort ? b.compareTo(a) : a.compareTo(b)); items.sort((String a, String b) => _reverseSort ? b.compareTo(a) : a.compareTo(b));
}); });
} },
), ),
new IconButton( new IconButton(
icon: new Icon(Icons.more_vert), icon: new Icon(Icons.more_vert),
tooltip: 'Show menu', tooltip: 'Show menu',
onPressed: () { showConfigurationSheet(context); } onPressed: () { showConfigurationSheet(context); },
)
]
), ),
body: new Scrollbar( ],
child: new MaterialList( ),
type: _itemType, body: new Scrollbar2(
child: new ListView(
padding: new EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0), padding: new EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0),
children: listItems children: listItems.toList(),
) ),
) ),
); );
} }
} }

View file

@ -58,13 +58,16 @@ class ShrinePageState extends State<ShrinePage> {
child: new Text('The shopping cart is empty') child: new Text('The shopping cart is empty')
); );
} }
return new MaterialList(children: config.shoppingCart.values.map((Order order) { return new ListView(
padding: const EdgeInsets.symmetric(vertical: 8.0),
children: config.shoppingCart.values.map((Order order) {
return new ListItem( return new ListItem(
title: new Text(order.product.name), title: new Text(order.product.name),
leading: new Text('${order.quantity}'), leading: new Text('${order.quantity}'),
subtitle: new Text(order.product.vendor.name) subtitle: new Text(order.product.vendor.name)
); );
}).toList()); }).toList(),
);
}); });
} }