I want to create a Google Map widget which will not handle any clicks, gestures - just a static map.
I understand I need somehow to set gestureRecognizers but can't figure out which class will lock all the gestures. What should I use instead of ScaleGestureRecognizer() ?
Setting gestureRecognizersto null doesn't help.
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()),
},
);
}
}
Try using AbsorbPointer
Make GoogleMap child of AbsorbPointer and set its absorbing property to true
return AbsorbPointer(
absorbing: true,
child: GoogleMap(
mapType: MapType.normal,
initialCameraPosition: cameraPosition,
gestureRecognizers: {
Factory<OneSequenceGestureRecognizer>(() => ScaleGestureRecognizer()),
}
)
);
You can also set it's absorbing property false when you want to detect events
For more info on AbsorbPointer refer here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With