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,
Can you include a small example that demonstrates the issue?
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.
A small example of what happens can be found in this gist
@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.
Most helpful comment
A small example of what happens can be found in this gist