繁体   English   中英

如何使 flutter Google 地图只能在 SingleChildScrollView 中用两根手指滚动

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM