Skip to content

Conversation

@bleroux
Copy link
Contributor

@bleroux bleroux commented Apr 19, 2024

Description

This PR adds some information about how the Material buttons padding is impacted by visual density.

Related Issue

Fixes #137411

Tests

Documentation only.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Apr 19, 2024
@bleroux bleroux requested review from HansMuller and gspencergoog and removed request for gspencergoog April 19, 2024 13:21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the default padding based on visualDensity or is the specified padding changed based on visualDensity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The padding is first resolved (the one specified if set, otherwhise the default one) then changed based on visual density.
Here is where this logic is located:

final double dy = densityAdjustment.dy;
final double dx = math.max(0, densityAdjustment.dx);
final EdgeInsetsGeometry padding = resolvedPadding!
.add(EdgeInsets.fromLTRB(dx, dy, dx, dy))
.clamp(EdgeInsets.zero, EdgeInsetsGeometry.infinity);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying that. Since this is somewhat unusual, it might be good to emphasize it a little. For example:

The vertical aspect of the default or user-specified padding is adjusted automatically based on visualDensity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this great rewording and for all the other suggestions (today I learned a new english word: wordsmithing 🎉)

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a nice improvement. Just some minor wordsmithing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// When the visual density is [VisualDensity.compact], the top and bottom paddings
/// When the visual density is [VisualDensity.compact], the top and bottom insets

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// are reduced by 8.0 pixels or set to 0 pixels if the result of the reduced padding
/// are reduced by 8 pixels or set to 0 pixels if the result of the reduced padding

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// is negative. E.g. The visual density defaults to [VisualDensity.compact] on desktop
/// is negative. For example: the visual density defaults to [VisualDensity.compact] on desktop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// and web, if the provided padding is 16 pixels on the top and bottom, it will be
/// and web, so if the provided padding is 16 pixels on the top and bottom, it will be

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// it will result to no padding on the top and bottom.
/// the result will be no padding on the top and bottom.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// are reduced by 4.0 pixels or set to 0 pixels if the result of the reduced padding
/// are reduced by 4 pixels or set to 0 pixels if the result of the reduced padding

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// When the visual density is [VisualDensity.standard] the top and bottom paddings
/// When the visual density is [VisualDensity.standard] the top and bottom insets

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// are not changed. E.g. The visual density defaults to [VisualDensity.standard]
/// are not changed. The visual density defaults to [VisualDensity.standard]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// on mobile,
/// on mobile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// reduced to 8 pixels on the top and bottom, if the provided padding is 4 pixels,
/// reduced to 8 pixels on the top and bottom. If the provided padding is 4 pixels,

@bleroux bleroux force-pushed the add_button_style_doc_mentionning_visualDensity_impact_on_padding branch from 9465fd1 to f7bce71 Compare April 23, 2024 07:33
@bleroux bleroux added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 23, 2024
@auto-submit auto-submit bot merged commit e9926c4 into flutter:master Apr 23, 2024
@bleroux bleroux deleted the add_button_style_doc_mentionning_visualDensity_impact_on_padding branch April 23, 2024 09:13
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 23, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 23, 2024
flutter/flutter@140edb9...77043ba

2024-04-23 [email protected] Roll Flutter Engine from ffd3911b1ff7 to 79f49954cce8 (2 revisions) (flutter/flutter#147235)
2024-04-23 [email protected] Roll Flutter Engine from c7d9deb66bf7 to ffd3911b1ff7 (1 revision) (flutter/flutter#147227)
2024-04-23 [email protected] Roll pub packages (flutter/flutter#147220)
2024-04-23 [email protected] Roll Flutter Engine from 075d834489d0 to c7d9deb66bf7 (2 revisions) (flutter/flutter#147215)
2024-04-23 [email protected] Mention visualDensity impact on ButtonStyle.padding documentation (flutter/flutter#147048)
2024-04-23 [email protected] Roll Flutter Engine from 9c0d24ff1cb6 to 075d834489d0 (1 revision) (flutter/flutter#147214)
2024-04-23 [email protected] Fix memory leaks in `CupertinoTextMagnifier` (flutter/flutter#147208)
2024-04-23 [email protected] Roll Flutter Engine from 004e98839ed7 to 9c0d24ff1cb6 (1 revision) (flutter/flutter#147211)
2024-04-23 [email protected] Roll Flutter Engine from 79f753650c6e to 004e98839ed7 (1 revision) (flutter/flutter#147209)
2024-04-23 [email protected] Roll Flutter Engine from f8e373da5227 to 79f753650c6e (1 revision) (flutter/flutter#147206)
2024-04-23 [email protected] fixes cupertino page transition leak (flutter/flutter#147133)
2024-04-23 [email protected] Fix memory leaks in `PopupMenu` (flutter/flutter#147174)
2024-04-23 [email protected] Roll Flutter Engine from 62c9f17169cf to f8e373da5227 (2 revisions) (flutter/flutter#147205)
2024-04-23 [email protected] Roll Flutter Engine from 33c828fb3ff5 to 62c9f17169cf (4 revisions) (flutter/flutter#147203)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.2 to 4.3.3 (flutter/flutter#147192)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.1 to 3.25.2 (flutter/flutter#147193)
2024-04-23 [email protected] Roll Flutter Engine from a4b71f02a1c7 to 33c828fb3ff5 (9 revisions) (flutter/flutter#147190)
2024-04-22 [email protected] Roll pub packages (flutter/flutter#147094)
2024-04-22 [email protected] Re-land fix for not disposed TabController (flutter/flutter#146745)
2024-04-22 [email protected] Roll Flutter Engine from 75ca2195c936 to a4b71f02a1c7 (1 revision) (flutter/flutter#147175)
2024-04-22 [email protected] Update `examples/api` for android platform (flutter/flutter#147102)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
flutter/flutter@140edb9...77043ba

2024-04-23 [email protected] Roll Flutter Engine from ffd3911b1ff7 to 79f49954cce8 (2 revisions) (flutter/flutter#147235)
2024-04-23 [email protected] Roll Flutter Engine from c7d9deb66bf7 to ffd3911b1ff7 (1 revision) (flutter/flutter#147227)
2024-04-23 [email protected] Roll pub packages (flutter/flutter#147220)
2024-04-23 [email protected] Roll Flutter Engine from 075d834489d0 to c7d9deb66bf7 (2 revisions) (flutter/flutter#147215)
2024-04-23 [email protected] Mention visualDensity impact on ButtonStyle.padding documentation (flutter/flutter#147048)
2024-04-23 [email protected] Roll Flutter Engine from 9c0d24ff1cb6 to 075d834489d0 (1 revision) (flutter/flutter#147214)
2024-04-23 [email protected] Fix memory leaks in `CupertinoTextMagnifier` (flutter/flutter#147208)
2024-04-23 [email protected] Roll Flutter Engine from 004e98839ed7 to 9c0d24ff1cb6 (1 revision) (flutter/flutter#147211)
2024-04-23 [email protected] Roll Flutter Engine from 79f753650c6e to 004e98839ed7 (1 revision) (flutter/flutter#147209)
2024-04-23 [email protected] Roll Flutter Engine from f8e373da5227 to 79f753650c6e (1 revision) (flutter/flutter#147206)
2024-04-23 [email protected] fixes cupertino page transition leak (flutter/flutter#147133)
2024-04-23 [email protected] Fix memory leaks in `PopupMenu` (flutter/flutter#147174)
2024-04-23 [email protected] Roll Flutter Engine from 62c9f17169cf to f8e373da5227 (2 revisions) (flutter/flutter#147205)
2024-04-23 [email protected] Roll Flutter Engine from 33c828fb3ff5 to 62c9f17169cf (4 revisions) (flutter/flutter#147203)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.2 to 4.3.3 (flutter/flutter#147192)
2024-04-23 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.1 to 3.25.2 (flutter/flutter#147193)
2024-04-23 [email protected] Roll Flutter Engine from a4b71f02a1c7 to 33c828fb3ff5 (9 revisions) (flutter/flutter#147190)
2024-04-22 [email protected] Roll pub packages (flutter/flutter#147094)
2024-04-22 [email protected] Re-land fix for not disposed TabController (flutter/flutter#146745)
2024-04-22 [email protected] Roll Flutter Engine from 75ca2195c936 to a4b71f02a1c7 (1 revision) (flutter/flutter#147175)
2024-04-22 [email protected] Update `examples/api` for android platform (flutter/flutter#147102)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect vertical padding for ElevatedButton from ButtonStyle

2 participants