Skip to content

Commit e9926c4

Browse files
authored
Mention visualDensity impact on ButtonStyle.padding documentation (#147048)
## Description This PR adds some information about how the Material buttons padding is impacted by visual density. ## Related Issue Fixes flutter/flutter#137411 ## Tests Documentation only.
1 parent 1f59013 commit e9926c4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,25 @@ class ButtonStyle with Diagnosticable {
210210
final MaterialStateProperty<double?>? elevation;
211211

212212
/// The padding between the button's boundary and its child.
213+
///
214+
/// The vertical aspect of the default or user-specified padding is adjusted
215+
/// automatically based on [visualDensity].
216+
///
217+
/// When the visual density is [VisualDensity.compact], the top and bottom insets
218+
/// are reduced by 8 pixels or set to 0 pixels if the result of the reduced padding
219+
/// is negative. For example: the visual density defaults to [VisualDensity.compact]
220+
/// on desktop and web, so if the provided padding is 16 pixels on the top and bottom,
221+
/// it will be reduced to 8 pixels on the top and bottom. If the provided padding
222+
/// is 4 pixels, the result will be no padding on the top and bottom.
223+
///
224+
/// When the visual density is [VisualDensity.comfortable], the top and bottom insets
225+
/// are reduced by 4 pixels or set to 0 pixels if the result of the reduced padding
226+
/// is negative.
227+
///
228+
/// When the visual density is [VisualDensity.standard] the top and bottom insets
229+
/// are not changed. The visual density defaults to [VisualDensity.standard] on mobile.
230+
///
231+
/// See [ThemeData.visualDensity] for more details.
213232
final MaterialStateProperty<EdgeInsetsGeometry?>? padding;
214233

215234
/// The minimum size of the button itself.

0 commit comments

Comments
 (0)