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

[BUG] MapOptions.applyPointerTranslucencyToLayers causes Positioned wrappers to fail #1740

Closed
Zverik opened this issue Nov 28, 2023 · 4 comments · Fixed by #1822
Closed

[BUG] MapOptions.applyPointerTranslucencyToLayers causes Positioned wrappers to fail #1740

Zverik opened this issue Nov 28, 2023 · 4 comments · Fixed by #1822
Assignees
Labels
bug This issue reports broken functionality or another error P: 1 (important) S: core Scoped to the core flutter_map functionality
Milestone

Comments

@Zverik
Copy link
Contributor

Zverik commented Nov 28, 2023

What is the bug?

I have been using Positioned extensively to place buttons around the map. This was validated by some of the examples. But those widgets are required to be placed in a Stack with no RenderObjects inbetween.

In 6.0.0 widgets, instead of being put in a Stack, are all wrapped in TranslucentPointer objects. Which leads to positioning not working, and multiple error notices in a log.

Can this thing you wanted to do be done differently? Or, are there alternatives to positioning widgets inside the map?

I thought of putting those on top of the map instead, but in that case those widgets (e.g. zoom buttons) won't have access to map state.

How can we reproduce it?

Use the Positioned widget as a top-level one for a map layer.

Do you have a potential solution?

Make applyPointerTranslucencyToLayers flag not wrap widgets, instead of setting a property of TranslucentPointer?

Alternatively, a way to properly upgrade such plugins needs to be documented. Align widget doesn't work for bottom-aligned buttons, for example.

Platforms

Android 12

Severity

Erroneous: Prevents normal functioning and causes errors in the console

@Zverik Zverik added bug This issue reports broken functionality or another error needs triage This new bug report needs reproducing and prioritizing labels Nov 28, 2023
@JaffaKetchup
Copy link
Member

Thanks for reporting.

Yes, this is an issue I didn't foresee. I didn't expect that a RenderObject non-Widget would cause issues.

It's worthwhile saying that non-map related widgets shouldn't be put inside the FM stack, but I can see that if a widget needs to access the context/inherited aspects, then it makes sense.

We actually did realise that this implementation might be an issue a couple of weeks ago, due to the fact that this will result in being able to press a button located behind another.

The real solution is to build layers (and fix the existing ones) to not handle taps when unnecessary, or individually wrap with the provided TranslucentPointer themselves if necessary. I think the best temporary solution is as you suggested.

As a short term workaround, put the buttons in a stack outside FM, and use a map controller as you may have done previously. Let me know if there's an issue with that.

@JaffaKetchup JaffaKetchup added P: 1 (important) and removed needs triage This new bug report needs reproducing and prioritizing labels Nov 28, 2023
@Zverik
Copy link
Contributor Author

Zverik commented Nov 28, 2023

So what I did was replacing Positioned with Align + Padding. That at first did not work for widgets with Columns inside them, but mainAxisSize: MainAxisSize.min fixed that.

@JaffaKetchup JaffaKetchup added the S: core Scoped to the core flutter_map functionality label Dec 10, 2023
@JaffaKetchup JaffaKetchup self-assigned this Dec 10, 2023
@JaffaKetchup JaffaKetchup added this to the v7.0 milestone Dec 10, 2023
@JosefWN
Copy link
Contributor

JosefWN commented Jan 9, 2024

It's worthwhile saying that non-map related widgets shouldn't be put inside the FM stack, but I can see that if a widget needs to access the context/inherited aspects, then it makes sense.

I use Positioned for the scale bar, for example, which is now broken 🥲

EDIT: Workaround by @Zverik worked for me too, thanks! Would probably be good to fix this anyway as it's a bit of a surprise.

@JaffaKetchup
Copy link
Member

We've just implemented native polyline tappability on 'master', and I'm planning on hopefully implementing tappability on polygons. Hopefully sorting out those will remove the need for the current translucency workaround, and resolve this issue.

@JaffaKetchup JaffaKetchup changed the title [BUG] Positioned regression for widgets [BUG] MapOptions.applyPointerTranslucencyToLayers causes Positioned wrappers to fail Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports broken functionality or another error P: 1 (important) S: core Scoped to the core flutter_map functionality
Projects
Archived in project
3 participants