![](/img/trans.png)
[英]How to make the user be able to move the google maps camera only with two fingers?
[英]How to make flutter Google Maps scrollable only with two fingers in SingleChildScrollView
我有这样的gestureRecognizers
参数集:
child: GoogleMap(
initialCameraPosition: widget.cameraPosition!,
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
new Factory<OneSequenceGestureRecognizer>(
() => new EagerGestureRecognizer(),
),
].toSet(),
但它只允许用一根手指滚动地图,但我希望它只能用两个手指? 我听说这是可能的,但如何?
看这里: https://gist.github.com/awaik/7d5b6d6ec644ae844a3740dddc990ed4
这是一个实现两个手指滑动的示例应用程序:
class SwipeDemo extends StatefulWidget {
const SwipeDemo({Key? key}) : super(key: key);
@override
SwipeDemoState createState() => SwipeDemoState();
}
class SwipeDemoState extends State<SwipeDemo> {
Offset offset = Offset.zero;
@override
Widget build(BuildContext context) {
return SafeArea(
child: TwoFingerPointerWidget(
onUpdate: (details) {
setState(() {
offset += details.delta;
});
},
child: Container(
alignment: Alignment.center,
color: Colors.white,
child: Transform.translate(
offset: offset,
child: Container(
width: 100,
height: 100,
color: Colors.red,
),
),
),
),
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.