Add more than 1 Marker, which is a same StatefulWidget.
In this case, we have more than 1 StatefulWidget and each StatefulWidget can have more than 1 it's State.
The problem occurs when scroll or move map, the State of StatefulWidget can rebuild and flutter maybe map StatefulWidget and State not exactly.
I try to add key to the StatefulWidget, flutter maybe rebuild State and map to StatefulWidget exactly but it rebuild a completely new State, so they lost the previous State of the StatefulWidget.
In my case, the StatefulWidget subscribe to the ValueNotifier to receive notification from server and change icon. When I scroll or move map the the notification on StatefulWidget change to another StatefulWidget. It likes the StatefulWidget changed to notification status become normal StatefulWidget and another normal StatefulWidget become notification status StatefulWidget
I find out the code if (!latlngBounds.contains(markerOpt.point)) {continue;} in marker_layer.dart can be a reason. So I fork to (https://github.com/lidroider/flutter_map), add alwaysKeepWidget to always add StatefulWidget Marker to Map.
So anyone have any idea or other solution for this issue?
p/s: sorry for my English
Add more than 1
Marker, which is a sameStatefulWidget.In this case, we have more than 1
StatefulWidgetand eachStatefulWidgetcan have more than 1 it'sState.The problem occurs when scroll or move map, the
StateofStatefulWidgetcan rebuild and flutter maybe mapStatefulWidgetandStatenot exactly.I try to add
keyto theStatefulWidget, flutter maybe rebuildStateand map toStatefulWidgetexactly but it rebuild a completely newState, so they lost the previousStateof theStatefulWidget.In my case, the
StatefulWidgetsubscribe to theValueNotifierto receive notification from server and change icon. When I scroll or move map the the notification onStatefulWidgetchange to anotherStatefulWidget. It likes theStatefulWidgetchanged to notification status become normalStatefulWidgetand another normalStatefulWidgetbecome notification statusStatefulWidgetI find out the code
if (!latlngBounds.contains(markerOpt.point)) {continue;}in marker_layer.dart can be a reason. So I fork to (https://github.com/lidroider/flutter_map), add alwaysKeepWidget to always addStatefulWidgetMarkertoMap.So anyone have any idea or other solution for this issue?
p/s: sorry for my English