Rami Dhouib
Rami Dhouib

Reputation: 11

Ignore drag mouse effect from parent of GoogleMap widget in flutter

I have a google map widget inside my program.

child: GoogleMap(
                  mapType: state.isSatellite ? MapType.hybrid : MapType.normal,
                  myLocationButtonEnabled: false,
                  initialCameraPosition: CameraPosition(
                    target: LatLng(
                      widget.initialLocation.latitude,
                      widget.initialLocation.longitude,
                    ),
                    zoom: widget.zoom,
                  ),
                  tiltGesturesEnabled: false,
                  scrollGesturesEnabled: !widget.staticPosition,
                  gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
                    Factory<OneSequenceGestureRecognizer>(
                      () => EagerGestureRecognizer(),
                    ),
                  },
                  onCameraMove: (position) {
                    bloc.add(
                      SetLocation(location: (
                        latitude: position.target.latitude,
                        longitude: position.target.longitude,
                      )),
                    );
                  },
                  onCameraIdle: () {
                    if (widget.staticPosition) {
                      bloc.add(SetCameraPosition(widget.initialLocation));
                    }
                  },
                  onMapCreated: (GoogleMapController controller) async {
                    _controller.complete(controller);
                    if (state.currentLocation.latitude != 0 &&
                        state.currentLocation.longitude != 0) {
                      await controller.animateCamera(
                        CameraUpdate.newLatLng(
                          LatLng(
                            state.currentLocation.latitude,
                            state.currentLocation.longitude,
                          ),
                        ),
                      );
                    }
                  },
                ),

Problem is this one is inside a singlechildscrollview , when I hold mouse and drag the position changes but also the page is dragged. I dont want the page to be dragged.Any ideas?

I tried AbsorbPointer() and IgnorePointer().

Upvotes: 0

Views: 22

Answers (1)

In the Google Map widget, you can customize the gestureRecognizers to avoid conflicts.

Upvotes: 0

Related Questions