为什么 Flutter 的 GoogleMap 的 onTap 功能没有被触发?



我有一个简单的小部件:

class TestGoogleMap extends StatelessWidget {
const TestGoogleMap({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Test Google Map'),
),
body: GoogleMap(
onTap: (LatLng ll) {
print('tapped Google Map');
},
initialCameraPosition: CameraPosition(target: LatLng(1.0, 1.0)),
),
);
}
}

当我点击地图时,没有输出。可能是什么问题?

编辑:我添加了一个长按功能,似乎每当我点击地图时,长按功能就会被触发。

我想你错过了谷歌地图中的这个链接

gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
new Factory<OneSequenceGestureRecognizer>(() => new EagerGestureRecognizer(),),
].toSet(),

最新更新