From ee7c72f4daa6d1e2b2f1bb0bfe365096d913fb60 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 9 Oct 2015 14:04:54 -0700 Subject: [PATCH] Make it fast to draw color icons Instead of using a ColorFilter, plumb the information down to Icon and thereby to Image. --- .../flutter/lib/src/material/icon_button.dart | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index a2b826d342..1103a3547a 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -10,26 +10,31 @@ import 'package:sky/widgets.dart'; import 'icon.dart'; class IconButton extends StatelessComponent { - const IconButton({ Key key, this.icon, this.onPressed, this.color }) : super(key: key); + const IconButton({ + Key key, + this.icon, + this.color, + this.colorFilter, + this.onPressed + }) : super(key: key); final String icon; - final Color color; + final IconThemeColor color; + final sky.ColorFilter colorFilter; final GestureTapCallback onPressed; Widget build(BuildContext context) { - Widget child = new Icon(type: icon, size: 24); - if (color != null) { - child = new ColorFilter( - color: color, - transferMode: sky.TransferMode.srcATop, - child: child - ); - } return new GestureDetector( onTap: onPressed, child: new Padding( - child: child, - padding: const EdgeDims.all(8.0)) + padding: const EdgeDims.all(8.0), + child: new Icon( + type: icon, + size: 24, + color: color, + colorFilter: colorFilter + ) + ) ); } }