我有一个 ListView,在它的顶部我有一张地图,我希望在滚动 ListView 时地图滚动出视图,但我也希望用户能够与地图进行交互。所以滚动应该只在用户在其他 ListView 小部件上滚动时发生,而不是在他们在地图上滚动时发生,然后我希望手势直接应用于地图。目前,当用户在地图上滚动时,它会滚动整个 ListView。
我已经尝试了我在这里遇到的另一个建议
在 Flutter 中,子小部件如何防止其可滚动父部件的滚动?
我GestureDetector在上面的帖子的答案中添加了一个将地图容器包装在下面的示例中的建议,但是这只是在地图上滚动时阻止了 ListView 和 Map 的滚动。视频链接https://imgur.com/SeCRzUC
这是我的构建方法返回的小部件。此代码取决于google_maps_flutter插件。
Container(
height: MediaQuery.of(context).size.height,
child:
ListView.builder(
itemCount: 12 + 1,
itemBuilder: (context, index) {
if (index == 0) return GestureDetector(
onVerticalDragUpdate: (_){},
child: Container(
height: MediaQuery.of(context).size.height / 2,
child: GoogleMap(initialCameraPosition: initalPosition),
),
);
else return ListTile(title: Text("$index"),);
}
)
),
Run Code Online (Sandbox Code Playgroud)
我曾希望地图会捕获手势,但它没有,包含它的列表视图会捕获所有手势。谁能建议我如何强制将列表中此项目的所有手势直接传递给地图,并且在滚动列表中的其他项目时仍然使列表滚动?
我设置我的场景如下:
document.addEventListener('mousedown', onDocumentMouseDown, false);
var container = document.getElementById("myCanvas");
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth*0.99, window.innerHeight*0.99 );
container.appendChild( renderer.domElement );
room_material = new THREE.MeshBasicMaterial({color: 0x00ff00});
room_material.side = THREE.DoubleSide;
objects = [];
camera.position.z = 19;
camera.position.x = 5;
camera.position.y = 30;
Run Code Online (Sandbox Code Playgroud)
我有一组对象,我试图检测点击是否与它们相交,定义如下:
var thing0 = new THREE.Shape();
thing0.moveTo(-12.1321728566, 35.3935535858);
thing0.lineTo(7.10021556487,35.3935535858);
thing0.lineTo(7.10021556487,19.7039735578);
thing0.lineTo(5.12636517425,19.7166264449);
thing0.lineTo(5.12636517425,33.6221493891);
thing0.lineTo(-12.1377356984,33.6439534769);
var thing0Geom = new THREE.ShapeGeometry(thing0);
var thing0Mesh = new THREE.Mesh( thing0Geom, room_material ); …Run Code Online (Sandbox Code Playgroud)