Skip to content

Commit e78b434

Browse files
blerouxPiinks
andauthored
Update ButtonStyle documentation (flutter#168062)
## Description This PR updates `ButtonStyle.minimumSize` and `ButtonStyle.fixedSize` documentation. It updates the documentation in order to describe the current behavior as it might be surprising. I have considered changing the behavior related to `ButtonStyle.minimumSize` but while experimenting I noticed that several widgets in the framework (and several tests) use `ButtonStyle.minimumSize` with the expectation that the given size is adjusted based on the ambient visual density (and there are probably several similar usages outside of the framework in Google and non-Google apps). ## Related Issue ButtonStyle.minimumSize : Fixes [minimumSize not respected properly when visual density is not standard](flutter#123528) ButtonStyle.fixedSize : Fixes [Button behaves differently in Web/Desktop and Mobile](flutter#85729) ## Tests Documentation only --------- Co-authored-by: Kate Lovett <katelovett@google.com>
1 parent e1499da commit e78b434

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/flutter/lib/src/material/button_style.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,23 @@ class ButtonStyle with Diagnosticable {
249249
/// See [ThemeData.visualDensity] for more details.
250250
final MaterialStateProperty<EdgeInsetsGeometry?>? padding;
251251

252-
/// The minimum size of the button itself.
252+
/// The minimum size of the button itself before applying [visualDensity].
253253
///
254254
/// The size of the rectangle the button lies within may be larger
255255
/// per [tapTargetSize].
256256
///
257257
/// This value must be less than or equal to [maximumSize].
258+
///
259+
/// The minimum size is adjusted automatically based on [visualDensity].
260+
///
261+
/// When visual density is [VisualDensity.compact], the minimum size is
262+
/// reduced by 8 pixels on both dimensions.
263+
///
264+
/// When visual density is [VisualDensity.comfortable], the minimum size is
265+
/// [minimumSize] reduced by 4 pixels on both dimensions.
266+
///
267+
/// When visual density is [VisualDensity.standard], the minimum size is
268+
/// [minimumSize].
258269
final MaterialStateProperty<Size?>? minimumSize;
259270

260271
/// The button's size.
@@ -263,6 +274,9 @@ class ButtonStyle with Diagnosticable {
263274
/// and [maximumSize]. Fixed size dimensions whose value is
264275
/// [double.infinity] are ignored.
265276
///
277+
/// The size of the rectangle the button lies within may be larger
278+
/// per [tapTargetSize].
279+
///
266280
/// To specify buttons with a fixed width and the default height use
267281
/// `fixedSize: Size.fromWidth(320)`. Similarly, to specify a fixed
268282
/// height and the default width use `fixedSize: Size.fromHeight(100)`.

0 commit comments

Comments
 (0)