When using flutter_map and flutter_map_marker_cluster to build map with marker I have a problem that sometimes but in quite long duration onTap not working anymore but it only occurred in iOS device. In android and iOS simulator it works normally.
Flutter Map {
layers: [
// Layer map cluster marker ---> HERE
MapCluster.getMapCluster(mapStateNotifier, mapState),
],
children: [
// map tile layer
TileLayerWidget(),
// Location user marker
CircleLayerWidget(),
// Compass marker
MarkerLayerWidget(),
],
}
// inside method MapCluster.getMapCluster
return MarkerClusterLayerOptions(
// void Function(Marker)?
onMarkerTap: (Marker marker) {
// ---> HERE
// show popup
}
);
I have tried
Increase size of Marker
Remove other layer, just only marker layer
Search issue in Flutter marker cluster package
I realized that running debug even not jump to break point inside onMarkerTap method when I tap on device. Sometimes it show smoothly, sometimes it so lag even though how many times I touch, it doesn't depend on zoom in/ out, go to background or sync/ async.
Because only iOS device has issue I think 2 packages flutter map & flutter marker cluster conflicts when handling gesture onTap in iOS but I have not find any evidence yet.
Finally, I figured it out. The reason is when using FlutterCompass I called StreamSubscription in init state and it always be called when rotate or shaking phone.
_compassStream = FlutterCompass.events?.listen((event) {
// update state with new value event.heading
});
Solution: