圆形图像文件 [英] Round Image File
问题描述
我执行了这段代码以从Firestore获取图像并将其用作地图标记的图标.
I did this code to get an image from firestore and use it as an icon for a Map Marker.
final StorageReference storageReference =
FirebaseStorage().ref().child("ProfilePictures/" + widget.userId);
String avatarDownloadPath = await storageReference.getDownloadURL();
final File _avatar = await DefaultCacheManager().getSingleFile(avatarDownloadPath);
Uint8List __avatar = await _avatar.readAsBytes();
BitmapDescriptor avatar = BitmapDescriptor.fromBytes(__avatar);
setState(() {
_markers.add(Marker(markerId: MarkerId("UserPosition"), position: userLocation, icon: avatar ));
});
此代码有效,但我想将图像设置为圆形,但我不知道该怎么做...
This code works but I want to set the image a round shape and I don't know how to do this...
如果您还知道如何像这样添加一个圆并为其设置动画,我将非常满意:
If you also know how to add a circle around and animate it like this I will be really satisfied:
(我没有找到更具代表性的东西,但我只想一个圆圈)
(I didn't find something more representative but I just want one circle)
推荐答案
您可以使用Canvas绘制圆形图像,并使用PictureRecorder保存为最终图像并将其放置在标记位图描述符fyi中:自定义标记
You can use use Canvas to draw a round image and use PictureRecorder to save as a final image and put it in the marker bitmapdescriptor, fyi: custom marker
在文章中用ImagePainter替换TextPainter
Replace TextPainter with ImagePainter in the article
OR
使用小部件自定义标记
这篇关于圆形图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!