I am using CustomPainter
to draw in flutter as per this question: Flutter: How to paint an Icon on Canvas?
final icon = Icons.cake;
TextPainter textPainter = TextPainter(textDirection: TextDirection.rtl);
textPainter.text = TextSpan(
text: String.fromCharCode(icon.codePoint),
style: TextStyle(fontSize: 20.0, fontFamily: icon.fontFamily));
textPainter.layout();
textPainter.paint(canvas, Offset(200.0, 200.0));
This works for Material Design Icons. However I would like to use the same techniqe to paint Font Awesome Icons. I am using the font_awesome_flutter 8.5.0 package, and this is my code:
final icon = Icon(FontAwesomeIcons.fish, size: 20, color: Colors.teal[700]);
TextPainter textPainter = TextPainter(textDirection: TextDirection.rtl);
textPainter.text = TextSpan(
text: String.fromCharCode(icon.codePoint),
style: TextStyle(fontSize: 20.0, fontFamily: icon.fontFamily));
textPainter.layout();
textPainter.paint(canvas, Offset(200.0, 200.0));
I am getting a message from the IDE saying that "The getter 'codePoint' isn't defined for the class 'Icon'". How can I fix this please?