【发布时间】:2022-01-04 18:36:36
【问题描述】:
我正在尝试为我的谷歌地图标记创建一个 bmp 图标。我需要动态添加不同的背景图片以适应循环中的圆圈。不太确定如何解决这个问题,因为我是新手,实际上有什么方法可以在尝试执行此操作时预览 mapbitdescriptor 吗?基本上,我需要在该循环中使用一个以图像为背景的圆圈。
Future<BitmapDescriptor> customBitMap(String imageUrl) async {
final myImage = await Image(image: AssetImage('assets/images/icon.png'));
final pictureRecorder = ui.PictureRecorder();
final canvas = Canvas(pictureRecorder);
final recordedPicture = pictureRecorder.endRecording();
final img = await recordedPicture.toImage(20, 20);
final data = await img.toByteData(format: ui.ImageByteFormat.png);
return BitmapDescriptor.fromBytes(data!.buffer.asUint8List());
}
【问题讨论】: