addImageFromIconData method
Create an image from IconData and add it to the map with the given id.
The size parameter defines the width and height of the resulting image
in pixels.
The color parameter defines the color of the icon. By default, it is
black.
Implementation
Future<void> addImageFromIconData({
required String id,
required IconData iconData,
int size = 200,
Color color = const Color(0xFF000000),
}) async {
await addImageFromCanvas(
id: id,
width: size,
height: size,
painter: (canvas) {
TextPainter(textDirection: TextDirection.ltr)
..text = TextSpan(
text: String.fromCharCode(iconData.codePoint),
style: TextStyle(
letterSpacing: 0,
fontSize: size.toDouble(),
fontFamily: iconData.fontFamily,
package: iconData.fontPackage,
color: color,
),
)
..layout()
..paint(canvas, Offset.zero);
},
);
}