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

Marker/Map rebuild causes marker to lose state #256

Closed
aytunch opened this issue Mar 26, 2019 · 6 comments
Closed

Marker/Map rebuild causes marker to lose state #256

aytunch opened this issue Mar 26, 2019 · 6 comments
Labels
bug This issue reports broken functionality or another error

Comments

@aytunch
Copy link
Contributor

aytunch commented Mar 26, 2019

I am animating some of the markers' opacity making them visible and invisible. Let's say I make one marker invisible. I can pan/zoom map and the marker stays invisible as expected as long as it is in screen bounds. This works well even if other markers leave the screen hence triggering markers to be rebuilt. But when the invisible marker goes out of screen and back in again, it is built as visible. I tried something like this using Keys hoping it would solve this situation. I am in need of help since I can not totally grasp the inner workings of Flutter_map @johnpryan @RaimundWege

return Marker {
    anchorPos: AnchorPos.exactly(Anchor(_kMarkerWidth / 2, 0)),
    width: _kMarkerWidth,
    height: _kMarkerHeight,
    point: LatLng(geopoint.latitude, geopoint.longitude),
    builder: (BuildContext ctx) {
        previousOpacity = getPreviousOpacity(table.tableId)  //I am trying to get previous state of this particular Marker and rebuild it with the old opacity.
        return UniversalWidget(   //statefulWidget
            key: ObjectKey(table.tableId),  //I tried all of these as well: UniqueKey, ValueKey, GlobalKey, Key
            opacity: previousOpacity,
@johnpryan
Copy link
Collaborator

Can you include a small example that demonstrates the issue?

@johnpryan johnpryan added the bug This issue reports broken functionality or another error label Jul 28, 2019
@GregorySech
Copy link
Contributor

Flutter keys do not keep State if no StatefulWidget is present with the same key so when the Marker is outside of the visible boundaries the builder will not be called and the associated StatefulWidget will not be rebuilt.
This triggers the disposal of State.
Maybe we could see how PageView and other widget keep their children states alive but right now the only way is to keep track of the state outside of the Marker.

@GregorySech
Copy link
Contributor

GregorySech commented Aug 27, 2019

A small example of what happens can be found in this gist

@aytunch
Copy link
Contributor Author

aytunch commented Dec 16, 2019

@GregorySech Hi Gregory, I assume you and @johnpryan are very busy lately. I would like to know if there are any work for version 0.8? Actually since using this awesome package for my app, I would indeed like to know if you have plans for maintaining this package in the future? Seems a long way for google_maps_flutter to support marker widgets hence making this package very important and unique. I haven't seen a new version in the last 3 months and would be glad to get feedback from you guys.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Mar 28, 2021
@github-actions
Copy link

github-actions bot commented Apr 2, 2021

This issue was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this as completed Apr 2, 2021
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
Projects
None yet
Development

No branches or pull requests

3 participants