From e9926c48482d871525344ab195e0a5f55ced9273 Mon Sep 17 00:00:00 2001 From: Bruno Leroux Date: Tue, 23 Apr 2024 10:15:53 +0200 Subject: [PATCH] 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 https://github.com/flutter/flutter/issues/137411 ## Tests Documentation only. --- .../lib/src/material/button_style.dart | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/flutter/lib/src/material/button_style.dart b/packages/flutter/lib/src/material/button_style.dart index d2c7dffca0..9d999b5ab9 100644 --- a/packages/flutter/lib/src/material/button_style.dart +++ b/packages/flutter/lib/src/material/button_style.dart @@ -210,6 +210,25 @@ class ButtonStyle with Diagnosticable { final MaterialStateProperty? elevation; /// The padding between the button's boundary and its child. + /// + /// The vertical aspect of the default or user-specified padding is adjusted + /// automatically based on [visualDensity]. + /// + /// When the visual density is [VisualDensity.compact], the top and bottom insets + /// are reduced by 8 pixels or set to 0 pixels if the result of the reduced padding + /// is negative. For example: the visual density defaults to [VisualDensity.compact] + /// on desktop and web, so if the provided padding is 16 pixels on the top and bottom, + /// it will be reduced to 8 pixels on the top and bottom. If the provided padding + /// is 4 pixels, the result will be no padding on the top and bottom. + /// + /// When the visual density is [VisualDensity.comfortable], the top and bottom insets + /// are reduced by 4 pixels or set to 0 pixels if the result of the reduced padding + /// is negative. + /// + /// When the visual density is [VisualDensity.standard] the top and bottom insets + /// are not changed. The visual density defaults to [VisualDensity.standard] on mobile. + /// + /// See [ThemeData.visualDensity] for more details. final MaterialStateProperty? padding; /// The minimum size of the button itself.