takeSnapshot method
Takes a snapshot of the current map and returns it as PNG bytes.
If width and height are given the snapshot is rendered at that size
(in logical pixels) by an offscreen renderer, keeping the current camera
position and style. When omitted the snapshot matches the current map
view size.
Implementation
@override
Future<Uint8List> takeSnapshot({int? width, int? height}) async {
try {
final result =
await _channel.invokeMethod<Uint8List>('map#takeSnapshot', {
if (width != null) 'width': width,
if (height != null) 'height': height,
});
if (result == null) {
throw Exception('Failed to take map snapshot');
}
return result;
} on PlatformException catch (e) {
return Future.error(e);
}
}