Skip to content
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

Margin is different than what I would expect #208

Open
bernaferrari opened this issue Feb 12, 2024 · 8 comments
Open

Margin is different than what I would expect #208

bernaferrari opened this issue Feb 12, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@bernaferrari
Copy link

bernaferrari commented Feb 12, 2024

Package version

No response

Flutter version

No response

Steps to reproduce

Screen.Recording.2024-02-12.at.13.11.49.mov

Expected results

I expect margin to not be included in the GestureListener, just like the web (
<a href="https://tailwindcss.com/docs" class="text-sky-500 hover:text-sky-600 bg-red-500 m-16">Read the docs &rarr;</a>)

Actual results

.

Code sample

Style(margin(16))

@leoafarias leoafarias added the enhancement New feature or request label Feb 21, 2024
@leoafarias
Copy link
Member

@bernaferrari This is not the behavior of Flutter, so I think a new widget will have to be created to have this behavior. I am working on a presentation using Mix as a demo to bring html into Flutter (still working on the title), but I think I can build an example.

@bernaferrari
Copy link
Author

Flutter barely has the margin concept. If you want a Button with a margin, the official way is Padding(child: Button).

@leoafarias
Copy link
Member

It does through the Container; however the, the events wrap the whole widget; that is why you see that behavior; we can extend a new widget or maybe even a decorator to help with this, but the current implementation is behaving correctly, but we will implement a solution for your case.

@Kypsis
Copy link

Kypsis commented Jun 8, 2024

There is another aspect to this and it is ensuring minimal touch target for the UX. Playing with the margin is one of the simpler implicit ways to ensure that for visually small interactive components eg CheckBox and Radio you can actually ensure that the finger can actually hit it with comfort without affecting the visual size of the widget. From my own experience using margin for layout purposes should be kept as last resort as there always better or more readable alternatives for layout or to achieve spacing.

@bernaferrari
Copy link
Author

bernaferrari commented Jun 8, 2024 via email

@Kypsis
Copy link

Kypsis commented Jun 9, 2024

Eh? Every touch interface makes some sort of affordance to increase touch area for interactables. Otherwise you would be hard pressed to ever hit those 12x12 checkboxes and radios. Or any sort of close button with X icon. Android,
iOS. The biggest issue imo with accounting for touch area is that it directly affects layout, so if you want to hit those UX accessibility goals your UI code can become seriously ugly.

@bernaferrari
Copy link
Author

bernaferrari commented Jun 9, 2024

Screenshot_20240609_093244_Settings

What you mentioned uses either a fixed size or padding.

Android doesn't use the tap touch target for anything like flutter does. It is just a please use padding. Flutter adds unwanted space sometimes which causes layout bugs. But even then, in Flutter, that's 100% padding.

@Kypsis
Copy link

Kypsis commented Jun 9, 2024

This shows layout bounds. That does not have to mean that is the extent of the touch area. The menu items on that screenshot function as one big touch area. The left arrow and the magnifying glass "buttons" are the real showcase of having to adjust components to meet the touch area target. Whether it's done by padding/margin, flex components with left or right alignment props or any other way is kind of beside the point, one way or other hoops are being jumped through to hit the minimal touch target.

If you are talking about Flutter making use of this crap in many components, then I agree with you. Yet one more example of Flutter team being very clueless or idealistic about scalable layouts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants