Flutter: How to paint an Icon on Canvas?
问题 I'm using a CustomPainter to draw in Flutter like this: @override void paint(Canvas canvas, Size size) { canvas.drawRect(...); canvas.drawImage(...); ... } How to draw an Icon on canvas ? 回答1: Create a Paragraph containing the code point in the correct font, style it as needed, then draw it. final icon = Icons.add; var builder = ui.ParagraphBuilder(ui.ParagraphStyle( fontFamily: icon.fontFamily, )) ..addText(String.fromCharCode(icon.codePoint)); var para = builder.build(); para.layout(const