From 50604c614e9bd836a0c5d5b9418daad04ca06e81 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Thu, 30 Sep 2021 23:18:02 -0700 Subject: [PATCH] Add a warning about Icon.size to IconButton (#91051) --- .../flutter/lib/src/material/icon_button.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index d3c65a6918..dd8ec4d772 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -49,6 +49,26 @@ const double _kMinButtonSize = kMinInteractiveDimension; /// ** See code in examples/api/lib/material/icon_button/icon_button.0.dart ** /// {@end-tool} /// +/// ### Icon sizes +/// +/// When creating an icon button with an [Icon], do not override the +/// icon's size with its [Icon.size] parameter, use the icon button's +/// [iconSize] parameter instead. For example do this: +/// +/// ```dart +/// IconButton(iconSize: 72, icon: Icon(Icons.favorite), ...) +/// ``` +/// +/// Avoid doing this: +/// +/// ```dart +/// IconButton(icon: Icon(Icons.favorite, size: 72), ...) +/// ``` +/// +/// If you do, the button's size will be based on the default icon +/// size, not 72, which may produce unexpected layouts and clipping +/// issues. +/// /// ### Adding a filled background /// /// Icon buttons don't support specifying a background color or other