gpt4 book ai didi

flutter - 静态谷歌地图(禁用所有手势)

转载 作者:IT王子 更新时间:2023-10-29 06:56:40 27 4
gpt4 key购买 nike

我想创建一个不会处理任何点击和手势的 Google map 小部件 - 只是一个静态 map 。我知道我需要以某种方式设置 gestureRecognizers 但无法确定哪个类将锁定所有手势。我应该使用什么来代替 ScaleGestureRecognizer()

gestureRecognizers 设置为 null 没有帮助。

When this set is empty or null, the map will only handle pointer events for gestures that were not claimed by any other gesture recognizer.

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

class StaticMap extends StatelessWidget {
final CameraPosition cameraPosition;
StaticMap(this.cameraPosition);

@override
Widget build(BuildContext context) {
return GoogleMap(
mapType: MapType.normal,
initialCameraPosition: cameraPosition,
gestureRecognizers: {
Factory<OneSequenceGestureRecognizer>(() => ScaleGestureRecognizer()),
},
);
}
}

最佳答案

尝试使用AbsorbPointer

制作 GoogleMap AbsorbPointer 并将其 absorbing 属性设置为 true

return AbsorbPointer(
absorbing: true,
child: GoogleMap(
mapType: MapType.normal,
initialCameraPosition: cameraPosition,
gestureRecognizers: {
Factory<OneSequenceGestureRecognizer>(() => ScaleGestureRecognizer()),
}
)
);

当你想检测事件时,你也可以设置它的absorbing属性false

有关 AbsorbPointer 的更多信息,请参阅 here

关于flutter - 静态谷歌地图(禁用所有手势),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56536399/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com