ImageIcon (#4649)
Anywhere that accepted IconData now accepts either an Icon or an ImageIcon. Places that used to take an IconData in an `icon` argument, notably IconButton and DrawerItem, now take a Widget in that slot. You can wrap the value that used to be passed in in an Icon constructor to get the same result. Icon itself now takes the icon as a positional argument, for brevity. ThemeData now has an iconTheme as well as a primaryIconTheme, the same way it has had a textTheme and primaryTextTheme for a while. IconTheme.of() always returns a value now (though that value itself may have nulls in it). It defaults to the ThemeData.iconTheme. IconThemeData.fallback() is a new method that returns an icon theme data structure with all fields filled in. IconTheme.merge() is a new constructor that takes a context and creates a widget that mixes in the new values with the inherited values. Most places that introduced an IconTheme widget now use IconTheme.merge. IconThemeData.merge and IconThemeData.copyWith act in a way analogous to the similarly-named members of TextStyle. ImageIcon is introduced. It acts like Icon but takes an ImageProvider instead of an IconData. Also: Fix the analyzer to actually check the stocks app.
This commit is contained in:
@@ -75,7 +75,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
|
||||
title: new Text('Advanced Layout'),
|
||||
actions: <Widget>[
|
||||
new IconButton(
|
||||
icon: Icons.create,
|
||||
icon: new Icon(Icons.create),
|
||||
tooltip: 'Search',
|
||||
onPressed: () {
|
||||
print('Pressed search');
|
||||
@@ -162,7 +162,7 @@ class MenuItemWithIcon extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return new Row(
|
||||
children: <Widget>[
|
||||
new Icon(icon: icon),
|
||||
new Icon(icon),
|
||||
new Padding(
|
||||
padding: new EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: new Text(title)
|
||||
@@ -263,7 +263,10 @@ class IconWithText extends StatelessWidget {
|
||||
return new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.collapse,
|
||||
children: <Widget>[
|
||||
new IconButton(icon: icon, onPressed: () { print('Pressed $title button'); } ),
|
||||
new IconButton(
|
||||
icon: new Icon(icon),
|
||||
onPressed: () { print('Pressed $title button'); }
|
||||
),
|
||||
new Text(title)
|
||||
]
|
||||
);
|
||||
@@ -290,7 +293,7 @@ class MiniIconWithText extends StatelessWidget {
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
shape: BoxShape.circle
|
||||
),
|
||||
child: new Icon(icon: icon, color: Colors.white, size: 12.0)
|
||||
child: new Icon(icon, color: Colors.white, size: 12.0)
|
||||
)
|
||||
),
|
||||
new Text(title, style: Theme.of(context).textTheme.caption)
|
||||
@@ -347,7 +350,7 @@ class UserHeader extends StatelessWidget {
|
||||
new Row(
|
||||
children: <Widget>[
|
||||
new Text('Yesterday at 11:55 • ', style: Theme.of(context).textTheme.caption),
|
||||
new Icon(icon: Icons.people, size: 16.0, color: Theme.of(context).textTheme.caption.color)
|
||||
new Icon(Icons.people, size: 16.0, color: Theme.of(context).textTheme.caption.color)
|
||||
]
|
||||
)
|
||||
]
|
||||
@@ -392,8 +395,14 @@ class ItemImageBox extends StatelessWidget {
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
new IconButton(icon: Icons.edit, onPressed: () { print('Pressed edit button'); }),
|
||||
new IconButton(icon: Icons.zoom_in, onPressed: () { print('Pressed zoom button'); })
|
||||
new IconButton(
|
||||
icon: new Icon(Icons.edit),
|
||||
onPressed: () { print('Pressed edit button'); }
|
||||
),
|
||||
new IconButton(
|
||||
icon: new Icon(Icons.zoom_in),
|
||||
onPressed: () { print('Pressed zoom button'); }
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
@@ -483,11 +492,11 @@ class ItemGalleryBox extends StatelessWidget {
|
||||
new Row(
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
icon: Icons.share,
|
||||
icon: new Icon(Icons.share),
|
||||
onPressed: () { print('Pressed share'); }
|
||||
),
|
||||
new IconButton(
|
||||
icon: Icons.event,
|
||||
icon: new Icon(Icons.event),
|
||||
onPressed: () { print('Pressed event'); }
|
||||
),
|
||||
new Flexible(
|
||||
@@ -555,7 +564,7 @@ class BottomBarButton extends StatelessWidget {
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new IconButton(
|
||||
icon: icon,
|
||||
icon: new Icon(icon),
|
||||
onPressed: () { print('Pressed: $title'); }
|
||||
),
|
||||
new Text(title, style: Theme.of(context).textTheme.caption)
|
||||
@@ -579,7 +588,7 @@ class GalleryDrawer extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
new FancyDrawerHeader(),
|
||||
new DrawerItem(
|
||||
icon: Icons.brightness_5,
|
||||
icon: new Icon(Icons.brightness_5),
|
||||
onPressed: () { _changeTheme(context, true); },
|
||||
selected: ComplexLayoutApp.of(context).lightTheme,
|
||||
child: new Row(
|
||||
@@ -594,7 +603,7 @@ class GalleryDrawer extends StatelessWidget {
|
||||
)
|
||||
),
|
||||
new DrawerItem(
|
||||
icon: Icons.brightness_7,
|
||||
icon: new Icon(Icons.brightness_7),
|
||||
onPressed: () { _changeTheme(context, false); },
|
||||
selected: !ComplexLayoutApp.of(context).lightTheme,
|
||||
child: new Row(
|
||||
@@ -610,7 +619,7 @@ class GalleryDrawer extends StatelessWidget {
|
||||
),
|
||||
new Divider(),
|
||||
new DrawerItem(
|
||||
icon: Icons.hourglass_empty,
|
||||
icon: new Icon(Icons.hourglass_empty),
|
||||
selected: timeDilation != 1.0,
|
||||
onPressed: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); },
|
||||
child: new Row(
|
||||
|
||||
@@ -147,7 +147,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable),
|
||||
new Divider(),
|
||||
new DrawerItem(
|
||||
icon: Icons.dvr,
|
||||
icon: new Icon(Icons.dvr),
|
||||
onPressed: () { debugDumpApp(); debugDumpRenderTree(); },
|
||||
child: new Text('Dump App to Console')
|
||||
),
|
||||
@@ -227,7 +227,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
|
||||
Widget buildDrawerColorRadioItem(String label, Map<int, Color> itemValue, Map<int, Color> currentValue, ValueChanged<Map<int, Color>> onChanged, { IconData icon, bool enabled: true }) {
|
||||
return new DrawerItem(
|
||||
icon: icon,
|
||||
icon: new Icon(icon),
|
||||
onPressed: enabled ? () { onChanged(itemValue); } : null,
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
@@ -244,7 +244,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
|
||||
Widget buildDrawerDirectionRadioItem(String label, DismissDirection itemValue, DismissDirection currentValue, ValueChanged<DismissDirection> onChanged, { IconData icon, bool enabled: true }) {
|
||||
return new DrawerItem(
|
||||
icon: icon,
|
||||
icon: new Icon(icon),
|
||||
onPressed: enabled ? () { onChanged(itemValue); } : null,
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
@@ -261,7 +261,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
|
||||
Widget buildFontRadioItem(String label, TextAlign itemValue, TextAlign currentValue, ValueChanged<TextAlign> onChanged, { IconData icon, bool enabled: true }) {
|
||||
return new DrawerItem(
|
||||
icon: icon,
|
||||
icon: new Icon(icon),
|
||||
onPressed: enabled ? () { onChanged(itemValue); } : null,
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
@@ -351,12 +351,12 @@ class CardCollectionState extends State<CardCollection> {
|
||||
}
|
||||
|
||||
// TODO(abarth): This icon is wrong in RTL.
|
||||
Widget leftArrowIcon = new Icon(icon: Icons.arrow_back, size: 36.0);
|
||||
Widget leftArrowIcon = new Icon(Icons.arrow_back, size: 36.0);
|
||||
if (_dismissDirection == DismissDirection.startToEnd)
|
||||
leftArrowIcon = new Opacity(opacity: 0.1, child: leftArrowIcon);
|
||||
|
||||
// TODO(abarth): This icon is wrong in RTL.
|
||||
Widget rightArrowIcon = new Icon(icon: Icons.arrow_forward, size: 36.0);
|
||||
Widget rightArrowIcon = new Icon(Icons.arrow_forward, size: 36.0);
|
||||
if (_dismissDirection == DismissDirection.endToStart)
|
||||
rightArrowIcon = new Opacity(opacity: 0.1, child: rightArrowIcon);
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class _FitnessDemoContentsState extends State<_FitnessDemoContents> {
|
||||
child: new Center(
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
new Icon(icon: icon, size: 48.0, color: color),
|
||||
new Icon(icon, size: 48.0, color: color),
|
||||
new Text(value, style: new TextStyle(fontSize: 24.0, color: color)),
|
||||
new Text(description, style: new TextStyle(color: color))
|
||||
]
|
||||
|
||||
@@ -87,13 +87,13 @@ class PageableListAppState extends State<PageableListApp> {
|
||||
child: new Block(children: <Widget>[
|
||||
new DrawerHeader(content: new Center(child: new Text('Options'))),
|
||||
new DrawerItem(
|
||||
icon: Icons.more_horiz,
|
||||
icon: new Icon(Icons.more_horiz),
|
||||
selected: scrollDirection == Axis.horizontal,
|
||||
child: new Text('Horizontal Layout'),
|
||||
onPressed: switchScrollDirection
|
||||
),
|
||||
new DrawerItem(
|
||||
icon: Icons.more_vert,
|
||||
icon: new Icon(Icons.more_vert),
|
||||
selected: scrollDirection == Axis.vertical,
|
||||
child: new Text('Vertical Layout'),
|
||||
onPressed: switchScrollDirection
|
||||
|
||||
Reference in New Issue
Block a user