Want to change the icon size of Google Maps marker in Flutter? Use the below example to change the icon size of Google Maps marker.
Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Future<Uint8List> getBytesFromCanvas(int width, int height, urlAsset) async { final ui.PictureRecorder pictureRecorder = ui.PictureRecorder(); final Canvas canvas = Canvas(pictureRecorder); final ByteData datai = await rootBundle.load(urlAsset); var imaged = await loadImage(new Uint8List.view(datai.buffer)); canvas.drawImageRect( imaged, Rect.fromLTRB( 0.0, 0.0, imaged.width.toDouble(), imaged.height.toDouble()), Rect.fromLTRB(0.0, 0.0, width.toDouble(), height.toDouble()), new Paint(), ); final img = await pictureRecorder.endRecording().toImage(width, height); final data = await img.toByteData(format: ui.ImageByteFormat.png); return data.buffer.asUint8List(); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.