-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Padding inside FilledButton have a different behavior on web when on Mobile Browser vs Desktop Browser #155768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report @c-lucera-pvotal |
Hey @darshankawar if you check the code, I have a button sized 40 in height, then I have a padding all of 16, this leaves only 8 (40, minus 16 top and 16 bottom) for the text, that should't be rendered, but it does, effectively masking any potential issue. here another sample with a 40 sized button with a vertical padding of 20 (sums to 40) for some reason the text instead of being invisible, it is just moved a little to the bottom SizedBox(
height: 40,
child: FilledButton(
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 20),
),
onPressed: () {},
child: const Text("test"),
),
), |
Thanks for the update. I see that the reported behavior also occurs on mobile and mobile browsers as compared to web and desktop wherein it renders properly. https://github.com/flutter/flutter/blob/a6f3a1b8b4b9553e88ae51cb939ed7842a12edba/packages/flutter/lib/src/material/filled_button.dart#L460C29-L460C53 it shows In your case,
If this is reduced to less than 16, then it does render the text properly |
The thing here is that the reported behavior is not correctly rendered on desktop, it renders correctly on mobile, due to the excessive padding the text should be not visible, but testing on desktop gives a false negative because the text is visible even when it shouldn't |
Thanks for the update and your patience while we try to figure this out. Please see this issue and likely related to visual density difference between mobile, desktop and web platforms. See https://api.flutter.dev/flutter/material/VisualDensity-class.html to get more details and to know if it helps in your case as why it could be occuring. |
I don't think it is related, that will change the size of the button, and it is somewhat expected, what is happening here, is that in desktop for some reason, the text appears even if it shouldn't, I explain it better we have a 200 sized height container, then we apply 100 padding top and 100 padding bottom, the space for the inner text becomes 0. This should cause an overflow error, or at least render the content not visible, but in desktop for some reason this doesn't happens, leading to false negatives (looking the UI looks correct while it shouldn't) I can check later if fiddling with the VisualDensity in theme is related to this however. |
Thanks for the update. Seeing the same behavior as reported with latest versions. Keeping this open for team's tracking.
|
May be related to #123528 |
Steps to reproduce
Expected results
The two test button looks the same
Actual results
The two button looks really different.
The button text is visible on a chrome browser on macOS.
The button text is not visible on a chrome browser on iPhone/Android.
The mobile version is probably the correct one, with the text being cropped by the height constraint + big padding, but the debug was difficult be cause on desktop it looked good.

Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
Logs
Logs
No interesting logs in the console
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: