当使用flutter_map和flutter_map_marker_cluster来构建带有标记的Map时,我遇到了一个问题,有时,但在相当长的时间内onTap不再工作,但它只发生在iOS设备中。在Android和iOS模拟器中,它工作正常。
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
}
);
我试过了
1.增加标记尺寸
1.移除其他图层,仅移除标记图层
1.Flutter标记集群 Package 中的搜索问题
我意识到,运行调试甚至没有跳转到断点内onMarkerTap方法,当我点击设备。有时它显示顺利,有时它如此滞后,即使我触摸了多少次,它不依赖于放大/缩小,转到后台或同步/异步。
因为只有iOS设备有问题,我认为在iOS中处理手势onTap时,2个包flutter map和flutter marker群集冲突,但我还没有找到任何证据。
1条答案
按热度按时间dy2hfwbg1#
最后,我想通了。原因是当使用FlutterCompass时,我在
init state
中调用了StreamSubscription,它总是在旋转或摇动手机时调用。溶液: